1

How can i create and Display KML file on Google Maps Any solution....

I have tried this code but its not working and also its for Version 1 and i want to implement on Google Maps V-2

How to draw Path on Map using KML file

Thanks In advance for any Help

Community
  • 1
  • 1
Mustanser Iqbal
  • 5,017
  • 4
  • 18
  • 36
  • Note Version 2 of the Google Maps JavaScript API is no longer available. You must migrate your solution to version 3. https://developers.google.com/maps/documentation/javascript/v2/services – CodeMonkey Aug 20 '14 at 13:41
  • @jason thanks for the reply man actually i got sick and couldn't check my email.... i want to implement this on android and i have done creating my own KML file and then done parsing to display exactly as it was created... but now i want to parse any KML sample file like [link](https://developers.google.com/kml/documentation/KML_Samples.kml) exactly as displayed on google map now i try to follow [link](https://github.com/micromata/javaapiforkml#java-api-for-kml) but i think that's for web Implementation correct me if m wrong... thanks for help – Mustanser Iqbal Aug 29 '14 at 06:03
  • You should be able to create HTML page using example below with a link to particular KML file to view and post that document in a public web site to access from your mobile (e.g., dropbox, google docs, etc.). javaapi4kml can be used for web implementation and generating KML on the fly from a server. – CodeMonkey Aug 29 '14 at 11:57
  • actually i don't wanna use any web server. and i have already done parsing by uploading file from external storage directory,also i have done creating new kml file and my question is how to display KML file like [this](https://kml-samples.googlecode.com/svn/trunk/interactive/index.html#./) any help shall be appreciated Thanks – Mustanser Iqbal Aug 29 '14 at 12:59

1 Answers1

0

The KmlLayer renders KML elements into a Maps API V3 tile overlay.

If you want to display an existing KML file using Google Maps API you can try something like this:

function initialize() {
  var location = new google.maps.LatLng(41.875696,-87.624207); // Chicago
  var mapOptions = {
    zoom: 11,
    center: location
  }

  var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

  var ctaLayer = new google.maps.KmlLayer({
    url: 'http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml'
  });
  ctaLayer.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);

The full working example with HTML + JavaScript can be found here. For more details see the KmlLayer Maps API Reference.

CodeMonkey
  • 22,825
  • 4
  • 35
  • 75