Google-Maps-for-Craft icon indicating copy to clipboard operation
Google-Maps-for-Craft copied to clipboard

Map is 100% zoomed in after GeoCoding with JS

Open mediagirl opened this issue 11 years ago • 7 comments

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

mediagirl avatar Sep 12 '14 18:09 mediagirl

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.

  1. Pass "fitBounds: false" in the list of options when you plot the markers. If you are using the craft.googleMaps.data data, it would be the second argument in the method. This will prevent the default behavior from occurring. You can then use the craft.googleMaps.center and craft.googleMaps.zoom tags to position the map accordingly. There are a few others ways to do it too using the options in the craft.googleMaps.map tag too.
  2. 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.

objectivehtml avatar Sep 12 '14 19:09 objectivehtml

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.

mediagirl avatar Sep 12 '14 19:09 mediagirl

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.

objectivehtml avatar Sep 14 '14 23:09 objectivehtml

I'd love the ability to override the default zoom after a location is plotted on the map in an entry.

mediagirl avatar Sep 22 '14 16:09 mediagirl

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?

objectivehtml avatar Sep 30 '14 04:09 objectivehtml

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.

mediagirl avatar Sep 30 '14 17:09 mediagirl

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.

echantigny avatar Apr 17 '15 18:04 echantigny