0

I want to use Geoxml3 to load a kmlfile on googlemap, the googlemap is loaded but the layer is not shown, i don't know what is wrong with my code, can anyone help?

<script type="text/javascript">
var mapInstance;
var parser;

function doAlert() {
        alert("Parsed triggered!");
}

function initialize() {
        console.log("in init");
        var latlng = new google.maps.LatLng(41.1188827, 1.24449090);
        var mapOptions = {
                zoom: 14,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP,
                mapTypeControlOptions: {
                style: google.maps.MapTypeControlStyle.DEFAULT
                }
        };
        mapInstance = new google.maps.Map(document.getElementById("map"), mapOptions);
        parser = new geoXML3.parser({
                map: mapInstance,
                zoom: false,
                processStyles: true,
                singleInfoWindow: true
                }
        );
        google.maps.event.addListener(parser, 'parsed', doAlert);       
        parser.parse('postes.kml');
}               
</script>
</head>
<body onload="initialize()">
        <div id="map" style="width: 100%; height: 100%"></div>
</body>
</html>
user3636199
  • 33
  • 1
  • 4
  • Your code works for me (I changed zoom to true and changed the KML file, as you didn't provide yours). [your code](http://www.geocodezip.com/geoxml3_test/v3_SO_geoxml3_20140514.html) – geocodezip May 14 '14 at 13:03

1 Answers1

0

You dont create the Marker you only parse the kml but dont set it to the map.This is some example Code from https://code.google.com/p/geoxml3/wiki/Usage

<script type="text/javascript">
    var myMap = new google.maps.Map(...);

    var myParser = new geoXML3.parser({
      map: myMap,
      processStyles: true,
      createMarker: addMyMarker,
      createOverlay: addMyOverlay
    });
    myParser.parse(['my_geodata1.kml', 'my_geodata2.kml']);

    function addMyMarker(placemark) {
      // Marker handling code goes here
      if (someCondition) {
        myParser.createMarker(placemark);
      }
    };

    function addMyOverlay(groundOverlay) {
      // Overlay handling code goes here
      if (someCondition) {
        myParser.createOverlay(groundOverlay);
      }
    };
  </script>
Aerox
  • 69
  • 3