jeffreykemp / jk64-plugin-reportmap

Report Google Map APEX Plugin
https://jeffreykemp.github.io/jk64-plugin-reportmap/
MIT License
43 stars 16 forks source link

Adding KML layers to map #162

Closed KenUPlayThat closed 2 years ago

KenUPlayThat commented 2 years ago

Hi Jeff,

Really like this plugin, but I'm a newbie to plugins and javascript. I have an APEX app that I support that has a lot of KML generated that then opens Google Earth to view. I want to use the plugin instead. I'm playing with your demo app Page 18 Google Map Layers and trying to add the layer shown https://developers.google.com/maps/documentation/javascript/kml.

If modified the "on change" Dynamic action code as follows but when I change the drop down, the kml doesn't display on the resulting map. I also tried removing "map: "#map_mymap"" from the lyr definition but that also didn't work.

Any help you can provide is greatly appreciated, Ken

if (typeof lyr==='object') { lyr.setMap(null); } delete lyr; switch ($v("P18_LAYER")) { case 'traffic': lyr = new google.maps.TrafficLayer(); break; case 'transit': lyr = new google.maps.TransitLayer(); break; case 'bicycling': lyr = new google.maps.BicyclingLayer(); break; }

lyr = new google.maps.KmlLayer('https://developers.google.com/maps/documentation/javascript/examples/kml/westcampus.kml, { suppressInfoWindows: true, preserveViewport: false, map: "#map_mymap" });

lyr.setMap( $("#map_mymap").reportmap("instance").map );

jeffreykemp commented 2 years ago

Hi Ken,

I think you're close. There's some code there you don't need, and I don't think your KmlLayer initialisation would even run in its current form due to syntax errors. Here's my suggestion for what to try:

lyr = new google.maps.KmlLayer({
    url: "https://developers.google.com/maps/documentation/javascript/examples/kml/westcampus.kml",
    suppressInfoWindows: true,
    preserveViewport: false,
    map: $("#map_mymap").reportmap("instance").map
});
KenUPlayThat commented 2 years ago

Hi Jeff,

That worked perfectly. Thanks for your help and comments!

Ken