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...?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

strk’s picture

Status: Active » Closed (works as designed)

Yes, 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.

BWPanda’s picture

Status: Closed (works as designed) » Active

I 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?

strk’s picture

I 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.

BWPanda’s picture

Title: How to make all maps zoom to layer? » Allow zoom-to-layer to apply to multiple layers
Version: 6.x-2.0-alpha10 » 6.x-2.x-dev
Component: OpenLayers Views » Behaviors
Category: support » feature

Cool, glad we got that sorted :)
Re-naming issue.

batje’s picture

subscribe

jeffschuler’s picture

subscribe

nan’s picture

Component: Behaviors » OL API

subscribe

partyp’s picture

subscribe

elyobo’s picture

jeffschuler’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Status: Active » Needs review
FileSize
4.07 KB

Here 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!

Status: Needs review » Needs work

The last submitted patch, openlayers-zoom_multiple_layers-928244-10.patch, failed testing.

wemmies’s picture

Title: Allow zoom-to-layer to apply to multiple layers » Work around for the time being?

This 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

wemmies’s picture

proxy triple posts

wemmies’s picture

proxy triple posts

wemmies’s picture

Title: Work around for the time being? » Allow zoom-to-layer to apply to multiple layers
jeffschuler’s picture

Status: Needs work » Needs review
FileSize
4.17 KB

Fixed:

-        '#default_value' => isset($defaults['zoomtolayer']) ? $defaults['zoomtolayer'] : NULL
+        '#default_value' => isset($defaults['zoomtolayer']) ? $defaults['zoomtolayer'] : array(),

Go, testbot, go!

cesareaugusto’s picture

Is this patch merged into the latest main dev release? Or should we manually apply it?

jeffschuler’s picture

@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...

Status: Needs review » Needs work

The last submitted patch, openlayers-zoom_multiple_layers-928244-18.patch, failed testing.

jeffschuler’s picture

Status: Needs work » Needs review
FileSize
4.17 KB

Sorry about that. Patching from right place...

Status: Needs review » Needs work

The last submitted patch, openlayers-zoom_multiple_layers-928244-20.patch, failed testing.

jeffschuler’s picture

Status: Needs work » Needs review
FileSize
4.21 KB

Pol’s picture

Tested & committed, thanks again Jeff' !

http://drupalcode.org/project/openlayers.git/commit/024d582

Pol’s picture

Status: Needs review » Fixed
sokrplare’s picture

Wow, 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Pol’s picture

Priority: Normal » Major
Status: Closed (fixed) » Needs work

I 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.

Pol’s picture

Status: Needs work » Fixed

Problem solved.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.