Skip to content

KmlOverlay

Masashi Katsumata edited this page Mar 27, 2015 · 15 revisions

###Add a KmlOverlay map.addKmlOverlay() adds geographic markup onto the map from a KML file. You can specify the file using one of the following protocols: http, https, file, cdvfile or the file absolute path. Only Android, also accepts file:///android_asset/. The added overlays are clickable.

PhoneGap-GoogleMaps-Plugin can parse only Polyline, Polygon, and Markers currently

Field Name Type Description
url String The url of the kml file (file path or network url)
preserveViewport Boolean Set true if prevent the camera animation after overlays are added. (Default: false)
animation Boolean Set false if you want to change the camera view without animation. (Default: true)
map.addKmlOverlay({
  'url': "www/polygon.kml"
}, function(kmlOverlay) {
  kmlOverlay.on(plugin.google.maps.event.OVERLAY_CLICK, function(overlay, latLng) {
    if (overlay.type == "Polygon") {
      overlay.setFillColor("red");
    }
    if (overlay.type == "Polyline") {
      overlay.setColor("blue");
    }
    if (overlay.type == "Marker") {
      overlay.showInfoWindow();
    }
  });
});

image


KmlOverlay Class Reference

Method Return value Description
getMap() Map Return the map instance.
remove() void Remove the kml overlay.
getOverlays() Array.<Polyline Polygon

Join the official community

New versions will be announced through the official community. Stay tune!

Do you have a question or feature request?

Feel free to ask me on the issues tracker.

Or on the official community is also welcome!


New version 2.0-beta2 is available.

The cordova-googlemaps-plugin v2.0 has more faster, more features.

https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/tree/master/v2.0.0/README.md

Clone this wiki locally