Google-Maps-for-Craft
Google-Maps-for-Craft copied to clipboard
Map is 100% zoomed in after GeoCoding with JS
I've used the new JS geocoding to plot markers on my maps from my address fields. All works well except the zoom level is 100% on the map when the entry form loads. Anyway to zoom it out a bit?
Here's a screenshot: http://screencast.com/t/y6ZtWERZMgP
By default, the map zoom in as close as it can and still contain all the objects on the map. So if you only have one marker on the map and do not want this behavior, you have a few options.
- Pass "fitBounds: false" in the list of options when you plot the markers. If you are using the
craft.googleMaps.datadata, it would be the second argument in the method. This will prevent the default behavior from occurring. You can then use thecraft.googleMaps.centerandcraft.googleMaps.zoomtags to position the map accordingly. There are a few others ways to do it too using the options in thecraft.googleMaps.maptag too. - If the above doesn't work, post your template code pertaining to the entries and map and I will take a look to see how else to do it.
I'm seeing the 100% zoom in the Control Panel on the entry edit form, not as a result of template code. Sounds like this is level of zoom is expected behavior.
Yeah, this is the expected behavior of the field type. If you have any other ideas on how to improve it, I am open to suggestions. I will say, I do like the current functionality so anything that is added should be done as an option to override the current functionality.
I'd love the ability to override the default zoom after a location is plotted on the map in an entry.
So do you want the ability to also save the zoom and center settings that are saved on the map? So perhaps an option for the user to set the map's center and zoom level and if that option is checked, the zoom and center will be used on the front-end automatically. Also, I would also foresee if this settings is set, the map would auto-center around all the objects on the map until the user changes it. Once changed, the center function would then always center the map on the position and zoom that the user set. If these values are ever changed by the user (by manipulating the map), the settings will also be saved to make these changes on the front-end. Make sense? Am I missing anything critical here?
For me as the developer turning the project over to the user, I just want to "zoom" the locations out a bit because with one location plotted, it's zoomed 100% into the map. It's more of a preference so probably doesn't need any additional functionality built in. Feel free to ignore this.
I personally think that the map should use the zoom setting we put in the field type for the entry edit form. 100% can be way too zoomed in for some more remote addresses. Ends up looking like a blank map.