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?
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.