tags:

views:

322

answers:

2

To test I saved this html file to my server. Is there a simple way to include a KML or KMZ file here?

<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt;  <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&amp;amp;v=2&amp;amp;key=ABCDEFghijetc&amp;sensor=false"
            type="text/javascript"></script>
    <script type="text/javascript">

    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(59.082089,5.649456), 18, G_SATELLITE_MAP);
        map.setUIToDefault();
      }
    }

    </script>   </head>   <body onload="initialize()" onunload="GUnload()">
    <div id="map_canvas" style="width: 800px; height: 600px"></div>   </body> </html>
+1  A: 

You'll have to covert a KML linestring to a Gmap Polyline which will involve a little bit of manual data manipulation, or an XML parser.

You could also try this on-line conversion tool.

bpowah
+2  A: 

Try adding the following JavaScript to your init function:

var kml = new GGeoXml("http://yoururl.com/yourfile.kml");
map.addOverlay(kml)

Note the KML must be a publically accessible URL, and there is a ~10MB limit:

http://code.google.com/apis/kml/documentation/mapsSupport.html

geographika