You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the map.zoomToLayer(myLayer) is called before the farmOS-map instance has been rendered in the DOM, the resulting map view is rendered poorly once the map is displayed. This happens in farmOS with collapsed fieldsets. Might be an easy fix?
Notably map.getSize() returns [0,0] before being rendered.
A potential fix might be defaulting to a lower zoom level (meaning less zoomed in) if the map size hasn't been set. I'm not sure if the maxZoom variable is used as a "default" zoom level though.
Another solution may be to default to a sensible map size (1000x400?) in the zoomToLayer function if the map hasn't been rendered yet. I'm assuming that the larger the map size, the further zoomed out the map would appear when rendered.
Example: map_zoom_demo (this previews an asset's location on the map after the user types. when the Geometry fieldset is collapsed, the map zooms poorly)
The text was updated successfully, but these errors were encountered:
Hmm yea rendering maps in collapsed fieldsets has caused issues many times for me. FWIW, we have some code in farm_theme specifically to trigger a map size update when fieldsets containing maps are expanded:
Auto-zooming in general is tricky. If different behaviors zoomToLayer() or zoomToVectors() at the same time, it can lead to weird behavior. In farmOS, I started to work around that by adding a zoom setting to some behaviors so that they could trigger zooming in some contexts but not others.
But that never felt like a perfect solution to me. It might be worth taking a step back and looking at how zooming works in general. Maybe we can overhaul it to be more sane. It's a bit tricky because we don't know what behaviors will be added to a given map, and yet we need some way of "prioritizing" which layer(s) get zoomed to.
If the
map.zoomToLayer(myLayer)
is called before the farmOS-map instance has been rendered in the DOM, the resulting map view is rendered poorly once the map is displayed. This happens in farmOS with collapsed fieldsets. Might be an easy fix?Notably
map.getSize()
returns[0,0]
before being rendered.A potential fix might be defaulting to a lower zoom level (meaning less zoomed in) if the map size hasn't been set. I'm not sure if the
maxZoom
variable is used as a "default" zoom level though.Another solution may be to default to a sensible map size (1000x400?) in the
zoomToLayer
function if the map hasn't been rendered yet. I'm assuming that the larger the map size, the further zoomed out the map would appear when rendered.Example: map_zoom_demo (this previews an asset's location on the map after the user types. when the Geometry fieldset is collapsed, the map zooms poorly)
The text was updated successfully, but these errors were encountered: