Add KML overlay to Google Maps

I'm trying to take a kml data and add it to a google map as an overlay.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:v="urn:schemas-microsoft-com:vml">

  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps API Example: GGeoXml KML Overlay</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA7_kD1t_m22HBF9feCaDPZxQqVU-Nu5zxWx1DXHBbCVSjdvSgHBRp_uleGkEg3oCH1fHjexeV2lXfgA"
      type="text/javascript"></script>

    <script type="text/javascript"> 
    var map;
    var geoXml; 
    function initialize() {

      if (GBrowserIsCompatible()) {

        geoXml = new GGeoXml("C:\Users\jj\Desktop\GoogleMaps\data.kml");

	  map = new GMap2(document.getElementById("map_canvas")); 

        map.setCenter(new GLatLng(38.1059,-101.1603), 4); 

        map.addControl(new GLargeMapControl());

    	  map.addOverlay(geoXml);

      }

    } 

   </script>
  </head>
  <body onload="initialize()">
    <div id="map_canvas" style="width: 640px; height: 480px; float:left; border: 1px solid black;"></div>

    </div>

    <br clear="all"/>

    <br/>

  </body>

</html>

Open in new window

DotNetNoobyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

COBOLdinosaurCommented:
Are you getting an error, or it just doesn't work?

Cd&
0
DotNetNoobyAuthor Commented:
just the map is showing up without anything on it
0
COBOLdinosaurCommented:
Okay.

The documentation for canvas is still pretty thin and I have sort of been learning as a go along to try and get ahead of it.  So, I don't guarntee I solve, but I'll try to help.

The first thing is you code does not look like the same sequence I have seen in some other scripts so try this:

function initialize() {

      if (GBrowserIsCompatible()) {

        geoXml = new GGeoXml("C:\Users\jj\Desktop\GoogleMaps\data.kml");

	  map = new GMap2(document.getElementById("map_canvas")); 
      map.addOverlay(geoXml); 
      context = map.getContext('2d');
      map.setCenter(new GLatLng(38.1059,-101.1603), 4); 
      map.addControl(new GLargeMapControl());
      }

    } 

Open in new window


If that does not work then I will have to do a little research.


Cd&
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.