How can I auto center and zoom my Smart Map with multiple markers? Something like this:
var bounds = new smartMap.map.LatLngBounds(); smartMap.map.fitBounds(bounds);
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.Sign up to join this community
So for starters, let's clear something up for anyone visiting this thread:
Beyond that, you can basically do anything you want with those JS variables. Much of that is beyond the scope of what I can help you with, but I'll try to at least point you in the right direction.
The way you'll want to refer to the map is like this:
By default, the map will be called "smartmap-mapcanvas-1" (or 2, 3, etc). But this value can be easily overridden when creating your map, by using the
id parameter in your
Now that you've got this map object, you can do anything you want via the Google Maps API.
When you're referring to individual markers, the format looks like this:
That naming scheme breaks into three separate components:
Now that you've got this marker object, you can do anything you want via the Google Maps API.
The format for marker info bubbles is nearly identical:
Now that you've got this info window object, you can do anything you want via the Google Maps API.
Finally, since it's not always clear what maps, markers, and info bubbles have been created, you have these three functions available to you for debugging purposes...
Hope that helps!
UPDATE: You no longer need to apply
As of Smart Map 2.3.0,
fitBounds will automatically be applied when rendering a map.