Add KML file as an overlay to the Google Maps window

How to add a KML file as an overlay when the code generating the Google Maps view looks like this:

<script type="text/javascript">
jQuery(document).ready(function($){
    jQuery('#google_map_1').gMap({
        zoom:7,
        markers:[{
            address:'',
            latitude:51.486782,
            longitude:-0.143242,
            html:'London, United Kingdom',
            popup:true
        }],
        controls:[],
        maptype:G_NORMAL_MAP,
        scrollwheel:false

    });


});

+3
source share
1 answer
var road = new google.maps.KmlLayer( 
    'http://MUST-BE-A-WEBSITE.com/myfile.kml',
    {preserveViewport:true}
    );

road.setMap(map);

usually this - pay attention to this huge work - there should be a website that is not a file served from localhost, somewhere that Google can analyze, analyze and integrate it with their maptiles. In addition, this example is gmaps v3 only. Other things to consider - including a list of KML files.

+3
source

All Articles