Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Javascript Error with using Google map in IE

Posted on 2006-11-05
10
Medium Priority
?
1,097 Views
Last Modified: 2008-01-09
Hi, I am using Google documentation example http://www.google.com/apis/maps/documentation/#Using_XML_and_Asynchronous_RPC
 Bu I got javascript error and it does not show all the markers in IE but that code works fine in firefox.

Here is my entire page:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html >
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>
    <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAt1tJUSGuvrApoZU9F246RRS2oTgyHBeaRCId_8WE_PRPpcBecRRhMqgKTHwwPYrzpZtPqzLXYsqDyA"
            type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[

    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(23.4419, 15.1419), 2);

        // Download the data in data.xml and load it on the map. The format we
        // expect is:
        // <markers>
        //   <marker lat="37.441" lng="-122.141"/>
        //   <marker lat="37.322" lng="-121.213"/>
        // </markers>
        GDownloadUrl("data.xml", function(data, responseCode) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
         for (var i = 0; i < markers.length; i++) {
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
            map.addOverlay(new GMarker(point));
          }
        });
      }
//      clearOverlays();
    }

    //]]>
    </script>
  </head>
  <body onload="load()" onunload="GUnload()">
    <div id="map" style="width: 790px; height: 300px"></div>
  </body>
</html>
0
Comment
Question by:Abdu_Allah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 16

Assisted Solution

by:Peter Kwan
Peter Kwan earned 800 total points
ID: 17876932
What javascript error do you get? Is your data.xml present in the same directory as the HTML resides?

I have tried your code in IE6 and found no error if the data.xml is present.
0
 
LVL 23

Accepted Solution

by:
rama_krishna580 earned 200 total points
ID: 17877312
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 17877645
>What javascript error do you get?

Line: 7
Char: 67
Error: Invalid Argument
Code: 0

>Is your data.xml present in the same directory as the HTML resides?

Yes
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Author Comment

by:Abdu_Allah
ID: 17877653
>I have tried your code in IE6 and found no error if the data.xml is present.

Did it show the entire markers?
0
 
LVL 5

Expert Comment

by:ewilde
ID: 17878856
i tried it too in ie6 & ie7 and in worked for me. the markers showed up as expected.
maybe you have some problem with your data.xml file?

i used this:

 <markers>
   <marker lat="37.441" lng="-122.141"/>
   <marker lat="37.322" lng="-121.213"/>
   <marker lat="37.122" lng="-121.213"/>
 </markers>


good luck,
ewilde.
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 17879713
This is really strange!
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 17879743
ewilde how your entire xml file look like, could you please copy&paste the entire file.
0
 
LVL 5

Assisted Solution

by:ewilde
ewilde earned 1000 total points
ID: 17880105
this is the whole of it:


 <markers>
   <marker lat="37.441" lng="-122.141"/>
   <marker lat="37.322" lng="-121.213"/>
   <marker lat="37.122" lng="-121.213"/>
 </markers>
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 17881275
Well, it seems the problem has disappeared by itself!! I did not do any changes!

However, ewilde  or anyone else, please try to add another <marker> nodes with different values, these new marker will not appear on the map! Is it a chashing problem? if so how to resolve it?
Thanks.
0
 
LVL 5

Assisted Solution

by:ewilde
ewilde earned 1000 total points
ID: 17886893
in order to force the browser to reload the data.xml you need to change the url every time you load it.  so do the folowing:

1. add this function to your script:

function createTimestamp(){
  return "timestamp=" + new Date().getTime().toString();
};

2. and use it when you load the data.xml file:

        GDownloadUrl("data.xml?"+createTimestamp(), function(data, responseCode) {


good luck,
ewilde.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question