Skip to content

Instantly share code, notes, and snippets.

@PerryRylance
Created June 17, 2020 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PerryRylance/462cafd319e2059da51b79b69f6b6a6c to your computer and use it in GitHub Desktop.
Save PerryRylance/462cafd319e2059da51b79b69f6b6a6c to your computer and use it in GitHub Desktop.
jQuery(function($){
$(document.body).on("init.wpgmza", function(event) {
var map = event.map;
var button = $("<button type='button'>Toggle KML</button>");
button.on("click", function(event) {
map.kmlLayers.forEach(function(layer) {
if(layer.getMap())
layer.setMap(null);
else
layer.setMap(map.googleMap);
});
});
$(map.element).before(button);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment