doublesecretagency / craft-googlemaps

Google Maps plugin for Craft CMS - Maps in minutes. Powered by the Google Maps API.
https://plugins.doublesecretagency.com/google-maps/
Other
10 stars 9 forks source link

Dynamic JS Method missing panBy #93

Closed sander-lameco closed 1 year ago

sander-lameco commented 1 year ago

I would like the use panBy but it seems to be missing in the Dynamic Maps JS.

The reason being is that we have something overlapping the Google Map and would like to offset the map a bit to counter this overlap.

lindseydiloreto commented 1 year ago

Hi @sander-lameco, sorry for the late reply.

Good news, you can access the underlying Google Maps API object at any time!

// Internally used Google API object
map._map

Meaning that you should be able to do something like this...

// Get the plugin's map object
const map = googleMaps.getMap(mapId);

// Pan using Google's map object
map._map.panBy(x, y);

Hope that helps!

sander-lameco commented 10 months ago

@lindseydiloreto thanks for the tip, but how do I check if googleMaps is available?. When trying your code I (of course) get googleMaps is not defined. I can't find anything in the docs related to this.

lindseydiloreto commented 9 months ago

If googleMaps is not defined, it means some dynamic JS is trying to run before the plugin's JavaScript files have been properly loaded.

The docs for Required JS Assets describe why those files are important, and how they can be automatically or manually loaded.