Skip to content

Instantly share code, notes, and snippets.

@xnau
Last active April 24, 2021 04:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save xnau/7d13c74f0a8d7b3dc7f3772d5b92e8f1 to your computer and use it in GitHub Desktop.
Shows how to add a KML file to a Participants Database Locations Map map.
<?php
// adds a KML to a a Google Map
add_filter( 'pdbgmap-additional_map_code', 'xnau_add_kml' );
/**
* adds a KML file to the map configuration
*
* this is based on the example at Google
* @see https://developers.google.com/maps/documentation/javascript/kml
* @param string $js_object empty string
* @return string a valid JS object
*/
function xnau_add_kml( $js_object ) {
return '
var src = "https://developers.google.com/maps/documentation/javascript/examples/kml/westcampus.kml";
var kmlLayer = new google.maps.KmlLayer(src, {
suppressInfoWindows: true,
preserveViewport: false,
map: map
});
';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment