Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have two map views and I want both of them to zoom to (and center over) the markers in them; however, as Views doesn't seem to provide an option for setting the layer to zoom to, I have to do it from the OpenLayers Preset settings, but that only lets me choose one layer to zoom to...
How to I make all maps zoom to their respective markers? Surely I don't have to create two separate map presets just for this functionality...?
Comments
Comment #1
strk CreditAttribution: strk commentedYes, you currently need to create different presets for different 'zoom-to' options.
Especially because there's no such thing as a "its respective marker". All markers (layer?) are of the same importance within a map/preset.
Comment #2
BWPanda CreditAttribution: BWPanda commentedI suppose I was expecting similar functionality to the preset's 'Pop Up' option... That let's you select (via checkboxes) different layers to have popups.
Why can't 'zoom to' do the same? I'm probably not understanding this properly, but if you say that there's no such thing as 'respective markers', how can popups be assigned to more than one layer?
Comment #3
strk CreditAttribution: strk commentedI must have misunderstood. If you want a _single_ map (a preset) to start by zooming to an extent enclosing
multiple vector layers than YES this is a valid feature request (not possible at the moment).
See if you can come out with a patch for the zoom_to_layer behavior, looking at the popup one or cluster one
for examples.
Comment #4
BWPanda CreditAttribution: BWPanda commentedCool, glad we got that sorted :)
Re-naming issue.
Comment #5
batje CreditAttribution: batje commentedsubscribe
Comment #6
jeffschulersubscribe
Comment #7
nan CreditAttribution: nan commentedsubscribe
Comment #8
partyp CreditAttribution: partyp commentedsubscribe
Comment #9
elyobo CreditAttribution: elyobo commentedThis info may be of use to any implementers - http://gis.stackexchange.com/questions/6283/in-openlayers-zoom-to-extent...
Comment #10
jeffschulerHere we go.
This adds the ability to choose multiple layers to which to zoom, and follows the route in the the doc mentioned in #9 (thanks @elyobo!) to extend bounds with each chosen layer. I'm storing "fullExtent" inside the map object so that layers with delayed processing (KML / GeoJSON) can get at it. There might be unhandled race conditions, but this is working for me.
Reviews appreciated!
Comment #12
wemmies CreditAttribution: wemmies commentedThis might be a workaround for as long there is no patch:
I also ran into this. I needed 3 layers to show different marker colors, with an exposed filter that made things zoom. Basically what i did was:
create the 3 layers and ad them to the map
create a 4th layer with all results from the 3 layers combined
I than enabled all 4 layers and only activated the first 3 layers (so the 4th layer markers don't show).
In settings I set the "zoom to" to the 4th layer with all results.
and that's it, I got the behavior I needed.
Hope this helps a bit
Comment #13
wemmies CreditAttribution: wemmies commentedproxy triple posts
Comment #14
wemmies CreditAttribution: wemmies commentedproxy triple posts
Comment #15
wemmies CreditAttribution: wemmies commentedComment #16
jeffschulerFixed:
Go, testbot, go!
Comment #17
cesareaugusto CreditAttribution: cesareaugusto commentedIs this patch merged into the latest main dev release? Or should we manually apply it?
Comment #18
jeffschuler@cesareaugusto: It's not in dev yet -- the patch needs to be reviewed by the community first. So, you'll need to apply the patch to 7.x-2.x-dev.
Here's a re-roll of it to apply cleanly.
Thanks for testing! Please report back here whether it worked for you...
Comment #20
jeffschulerSorry about that. Patching from right place...
Comment #22
jeffschulerComment #23
PolTested & committed, thanks again Jeff' !
http://drupalcode.org/project/openlayers.git/commit/024d582
Comment #24
PolComment #25
sokrplare CreditAttribution: sokrplare commentedWow, that's timing - just needed this feature today and then found this - marked as fixed - yesterday!
I think there is a bug, but could be mistaken, when there is a non-kml and non-geojson, single-point, single-layer. Filed a new issue at #1708514: Bug in "Allow zoom-to-layer to apply to multiple layers" patch with a one-line patch since this one was already committed. Wanted to post here though since everyone on this thread will care about the bug.
Comment #27
PolI tested during a few hours why this is still broken, I didn't not succeeded to find, I'm looking for help on this.
Try the 'Example GeoJSON' map, you'll see that the map doesn't center on the feature added by geojson.
Comment #28
PolProblem solved.