Hello,

I'm using gmap with a view of locations. This view has an exposed "Location: Distance / Proximity" filter that the user can use to find locations near her. Attached is a patch to the gmap_plugin_style_gmap.inc which adds an option "Center on proximity filter" (very similar to the "Center on node argument" option) to cause the center of the map to be where the user is searching.

I'm a little confused about the relationship between the 'gmap' module which provides the views style plugin and the 'location' module, because 'gmap' doesn't actually depend on 'location'. So, I tried to wrap my changes with checks for the 'location' module, but I may not have gotten it right.

Please let me know what you think!

Thanks,
David.

Comments

Clint Eagar’s picture

Works great. One suggestion, also add a zoom feature. So that when a user searches it not only centers on their search but also zooms.

dsnopek’s picture

Hrm. Where should it get the zoom value from? This patch basically just copies the latitude/longitude from the filter to be used to center the map. It has no zoom value to copy.

If you're looking for something that automatically centers/zooms so that all the points fit, the gmap module already has that. On the configuration page, select the "autozoom" behavior.

Unfortunately, these two features "conflict" in the sense that "autozoom" will change the center from whatever this patch sets it to. But I think they are for different use cases. This patch is if you want the center to be on what was searched for and "autozoom" is for if you want the center in the middle of the data points.

Hope that helps!

Regards,
David.

Johnny vd Laar’s picture

Version: 6.x-1.1 » 7.x-1.x-dev
StatusFileSize
new3.83 KB

The attached patch works in the drupal 7 version.

Anonymous’s picture

patch in post #1 works on drupal 6... amazing work, people!

dimon00’s picture

Very useful, thank you.

gazwal’s picture

StatusFileSize
new72.84 KB

adds an option "Center on proximity filter" (very similar to the "Center on node argument" option) to cause the center of the map to be where the user is searching.
screen exemple below

Frederic wbase’s picture

i've tested the patch for D7 on the latest dev and it works like a charm! Nice job and thanks for the hard work :-)!

heylookalive’s picture

Hi @dsnopek, @Johnny vd Laar great stuff!

I needed this but for views 3 contextual filters/arguments so here's a patch.

Note this is Drupal 7, and does not rely upon the previous patches (will work without the filter patches).

Johnny vd Laar’s picture

This patch attaches the same functionality for gmapextended

podarok’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
StatusFileSize
new4.84 KB

#9 rerolled agaist latest head
commited / pushed to 7.x-2.x

thanks!

podarok’s picture

the same pushed to 7.x-1.x branch

thanks!

podarok’s picture

Status: Needs review » Fixed
StatusFileSize
new2.31 KB

#8
removed whitespaces

commited to 7.x-2.x and 7.x-1.x

thanks!!

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Fixed some type-o's.

asad.hasan’s picture

What patch works for d6? @Careless post #1 has no patch.

aj2’s picture

Issue summary: View changes
StatusFileSize
new2.63 KB

It appears that the "relative" center on proximity patch is missing. I copied the code from the gmap extended patch #9 to get working. Otherwise the map is centered on proximity without any local markers. Patch included.