Say one has a small map, 300 x 300 px, and a single marker. The marker could be a geocoded street address or country taxonomy term. Different zoom levels would be required for a better user experience. One could set the average zoom in a map definition. However, what if one could set the zoom based on what was geocoded?
I've attached a work-in-progress for the addressfield type. It sets the zoom according to the fields that were completed. It might benefit from fine-tuning.
I noticed there's an unused accuracy column in geofield. Perhaps that could be of use in future.
Comments
Comment #1
rdeboerSmart idea! I like it. Thanks for sharing.
Comment #2
pvhee commentedWe probably should add an option in the map definition to either set the map zoom level to 'auto' (and use your patch above, nice work), or to a specific zoom level.
Comment #3
denix commentedNice idea, but manually setting the zoom still remain a priority.
Comment #4
pvhee commentedManually setting the zoom is now possible using the "zoom" option in hook_leaflet_map_info.
It will then always use that zoom level, so for one marker, but also multiple marker maps you perfectly control the zoom level now.
Comment #5
denix commentedThis is a great improvement, what is blocking for the release of a beta2 module? your module changed a lot since the beta1 version. great and nice work anyway.
Comment #6
pvhee commentedUnless comments from #2 are addressed, this won't enter in a new release. The zoom level definition from the hook is already in, and you can check out a dev release while a new release is being prepared.
Comment #7
gmclelland commentedI tried creating a custom module that implements this hook, but my map only shows a grey box with a pin in the middle. The map is a leaflet view.
I'm able to select the map definition in the leaflet view. Any idea of what I'm doing wrong?
Comment #8
gmclelland commentedWell, it seems to work fine without Panels using the leaflet map as a formatter on a geofield. I'm not sure what is going on. My view was a content pane.
Comment #9
levelos commentedThis has been addressed in subsequent releases.
Comment #10
n20 commentedConfirm using 0.75 works. But only fixed zoom levels seem to work. Using the option 'Use map defined setting' results in gray tiles.
Comment #11
n20 commentedMh, placing a second marker in some distance makes the map working with automatic zoom level. Only with a single marker and the resulting maximum zoom level the map gets grey. Using single marker and zooming out works for me.
Comment #12
n20 commentedMh, placing a second marker in some distance makes the map working with automatic zoom level. Only with a single marker and the resulting maximum zoom level the map gets grey. Using single marker and zooming out works for me.