Pregunta

Para probar he salvado este archivo html en mi servidor. ¿Hay una manera sencilla para incluir un archivo KML o KMZ aquí?

<!DOCTYPE html "-//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">  <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;v=2&amp;key=ABCDEFghijetc&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>
¿Fue útil?

Solución

Trate de añadir el siguiente JavaScript a su función init:

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

Tenga en cuenta el KML debe ser una URL de acceso público, y hay un límite de 10 MB ~:

https://developers.google.com/kml/documentation/mapsSupport

Otros consejos

Vas a tener para convertir un KML serie lineal a un Gmap polilínea que implicará un poco de manual de la manipulación de datos, o un analizador XML.

También puede probar esto en línea herramienta de conversión .

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top