Waqas Ahmed
Waqas Ahmed

Reputation: 98

Loading KML layer on Google map using Geoxml3

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">
jQuery(document).ready(function () {        
var myOptions = {
        center: new google.maps.LatLng(39.397, -100.644),
        zoom: 4,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var geoXml = new geoXML3.parser({
        map: map,
        singleInfoWindow: true,
        afterParse: useTheData
    });
    geoXml.parse('KML_Samples.kml');
    });

    function useTheData(doc) {
    // Geodata handling goes here, using JSON properties of the doc object
    for (var i = 0; i < doc[0].markers.length; i++) {
        console.log(doc[0].markers[i].title);
        jQuery('#map_text').append(doc[0].markers[i].title + ', ');
    }
    };
</script>

</head>
<body >
 <form id="form1">

    <div id="map_canvas" style="width:600px;height:500px;"></div>

    <div id="map_text"></div>
    </form>
    </body>
    </html>

Upvotes: 1

Views: 10881

Answers (1)

geocodezip
geocodezip

Reputation: 161334

Your code, at least as much as you posted works fine for me.

Here is a working example

Upvotes: 1

Related Questions