Here is a patch that allows users to select multiple locations on a node on a single map instead of a map for each location.
It creates a setting in the location settings for a content type that allows you to choose between having the normal map per location or a single map for all locations.
To have this work with a single map you also need to apply this gmap patch #338740: Display locations as polygons on gmap views, which has the new javascript required for this to work.
This is very useful for seeing all your locations together and means that only one gmap has to be rendered instead of one for each location.
The patch also adds Location: Location ID as a sort column for views, which can be useful if you are displaying polygons on a gmap view.
Please try it out and give feedback. It has been quite useful to us.
| Comment | File | Size | Author |
|---|---|---|---|
| #50 | location_test.txt | 10.2 KB | kbk |
| #50 | location_test.png | 355.92 KB | kbk |
| #49 | location-6x-singlemap-338745-49.patch | 11.81 KB | rooby |
| #48 | location-6x-singlemap-338745-48.patch | 11.84 KB | rooby |
| #36 | location_single_map_5x-3x_3.patch | 11.79 KB | agileware |
Comments
Comment #1
socialnicheguru commentedsubscribing
Comment #2
likewhoa commented++
Comment #3
aren cambre commentedsubscribing. I am on 6.x, so I would love to see this make it there.
Comment #4
summit commentedSubscribing for D6 version also!
Thanks for considering!
greetings,
Martijn
Comment #5
socialnicheguru commentedcool! subscribing
Comment #6
aren cambre commentedBTW, I would love to see this because I need to create a site where I show neighborhood boundaries. It's difficult to show them using a marker in the center of an arbitrary collection of streets. I sure hope this can make it into 6.x production use.
Comment #7
aren cambre commentedMy understanding is this needs to go into the 6.x line first. Changed to "needs work" state since supplied patch is for 5.x.
Comment #8
yesct commentedAgileware, Does this work with only the user or node native location fields, or only with the cck locations, or both? :)
Does the polygon get stored as the location, or is each point on the edge of the polygon it's own location?
Comment #9
agileware commentedI have used it only for cck locations.
I haven't looked at the native node and user location fields but it should work with them as they are just stored in the database as usual and then the gmap views plugin handles making the points into a polygon.
Comment #10
yesct commentedCan someone re-roll this against 6.x dev?
Comment #11
agileware commentedIt is dependent on the patch for gmap that I mentioned in the original issue too so that has to be ported to 6 too.
The reason for that is gmap javascript changes are necessary for this patch to work.
Probably a good idea would be to split that patch into two - One for the multiple locations part and one for the displaying polygons on the gmap view.
This would make it easier to get this functionality in as the main changes in the port to 6 of the gmap patch would relate to the gmap views changes (which aren't needed for this to work).
Comment #12
agileware commentedActually I had a bit of a brain freeze at #9
I have used it for node locations only.
Comment #13
agileware commentedI have now split the gmap patch that goes with this one.
The patch at #338740: Display locations as polygons on gmap views now only handles displaying locations as polygons on a gmap view.
I have created a new issue at #434290: Multiple locations on a single gmap, which is specifically for multiple locations on a single map.
They are both still d5 patches but I will work on porting them to d6 sometime in the next week when I have time.
Comment #14
yesct commentedgreat idea! thanks!
Comment #15
yesct commentedtagging
Comment #16
agileware commentedGoing to start working on a patch for this for drupal 6 now.
Comment #17
agileware commentedHere it is.
This patch is for 6.x-3.x-dev (2009-Apr-18).
It will also apply to 6.x-3.1-rc1 with offsets.
The patch works for node locations and user locations.
Where you select how many locations to have you can also select single map.
There is also an option at admin/settings/location called 'Updating a location creates a new location'.
The default for this option is TRUE, which will give you the same functionality you get normally in the location module.
In my usage, un-checking this option is the way to go.
Please test this and let me know if you come across any issues.
*And remember, you need the patch for gmap here - #434290: Multiple locations on a single gmap
Comment #18
yesct commentedjustin, awesome! thanks. Did you see the new #drupal-geo irc channel?
Comment #19
agileware commentedWhile I was porting this patch to 6 I made the patch work much cleaner. So consider the 5 patches I have for this previously as outdated and for a 5 patch I will port the current 6 one back.
Also, part of this patch is fixing a bug with the ordering of locations. This was fixed by ordering the location_load_locations query by lid and implementing the partly existing copy on write functionality. Seeing as that location ordering bug has it's own issue now I will split that part out into a patch for that issue, which is here - #356059: Multiple locations are saved in the wrong order.
Comment #20
agileware commentedTo any of you that were awaiting the D6 version of this patch:
Has anyone had a chance to test this yet?
Comment #21
aren cambre commentedNot clear if this is related, but I got this error when enabling modules:
Fatal error: Only variables can be passed by reference in /home/arencambre/drupal6/sites/gardenlakedistrict.org/modules/location/contrib/location_taxonomy/location_taxonomy.module on line 43Still testing...
Comment #22
aren cambre commentedOK, I'm confused, and this may be my ignorance of GMap, but if I have this, #434290: Multiple locations on a single gmap, and #338740: Display locations as polygons on gmap views installed, shouldn't I be able to select the boundaries (locations) of the node on a map? I don't see where this is done.
I do have the Google Maps API installed; I can do the Build a GMap macro.
Comment #23
izmeez commentedsubscribing
Comment #24
agileware commentedWith #338740: Display locations as polygons on gmap views you can display a group of locations as polygons on a map instead of markers. This works independently of #434290: Multiple locations on a single gmap, which is why they were split into separate patches.
Being able to select multiple locations on a single map just makes things easier.
To have node locations as polygons on a gmap view:
So you would set up the location & gmap modules as normal. You will want to uncheck the 'Updating a location creates a new location' checkbox on the admin/settings/location page or else your polygons might not come out the way you expect.
Then you go to the content type you are using for the location information, for example, for the page content type you would go to admin/content/node-type/page (or if you are doing locations for users instead of node you go to admin/user/settings).
On that page set your location settings - You need to allow at least 3 locations. You can use the single map option or not, it makes no difference.
Then create a node of that type with at least 3 location points.
Then set up a gmap view with polygons as the marker type - I won't go into exact details of creating this view here but there is a file that will get created by the polygon patch called gmap.views_default.inc. This file should set up a default view that will work for node polygons and another for user polygons. In my testing views does not pick up these default views but you can use the code in that file in a views import and it will set up the view for you.
Comment #25
aren cambre commentedUpdating a location creates a new location was checked, now it's unchecked. I also have Use a Google Map to set latitude and longitude checked.
In admin/content/node-type/organization I have min locations at 0, max at 100. Number of locations that can be added at once is 3.
For some reason clicking on the map above the locations does nothing.
I cleared out everything under Location in admin/build/modules then uninstalled all their data through admin/build/modules/uninstall. Then I installed these modules: GMap, GMap Location, Location, and Node Locations. Still have the same problem.
Any chance these patches interfere with this? The patches were installed on GMap 6.x-1.x-dev (2009-Jun-08) and Location 6.x-3.x-dev (2009-Apr-17).
Should I re-patch? If so, with what versions?
Comment #26
agileware commented@ Aren Cambre
I have just checked the patches again.
All patches (#338740: Display locations as polygons on gmap views, #434290: Multiple locations on a single gmap and this one) will apply to current dev versions with patch -p0 (most recent tested for location module is 2009-Jun-30).
The three patches will not interfere with each other as they apply to different areas of the code.
I have tried on a clean site, installing the patched gmap and location modules and it works.
I also have a site already set up with normal gmap and location modules, which I then patched with the three patches (you can omit the polygons patch if you only want the single map functionality).
I then set up as you did in #25 with the same location settings page values and the same min, max and added at once location values.
I go to the node/add/page screen and the maps worked as expected.
I then went back to admin/content/node-type/page and in the locative information settings, in the number of locations fieldset, I checked the single map option.
I go to the node/add/page screen and the maps worked as expected.
I'm not sure what could be the problem you are having. If all your patches have applied correctly it should be working.
If nothing is happening when you click the map it could be a javascript error.
Can you check to see if you are getting any javascript errors on the page where the map isn't working?
"For some reason clicking on the map above the locations does nothing."
- By this do you mean no marker appears and nothing goes into the lat/lon fields?
Comment #27
agileware commentedHere is a new patch that now works properly when also using the OG User Roles module.
The original patch had problems when creating nodes with locations on the node/ognodeadd screens as it was expecting node/add.
This might also cause problem with other modules that alter the node/add url so if there are any other you want me to check let me know.
Comment #28
agileware commentedHere is the patch in #27 ported for drupal 5.
It is a much better solution than the original drupal 5 patch and it goes with the gmap patch in #434290: Multiple locations on a single gmap comment 10.
It is for location 5.x-3.x-dev (2009-Jul-09) but it will also apply to 5.x-3.1-rc1.
Comment #29
summit commentedLooking forward for dev version with this patch!
Greetings, Martijn
Comment #30
agileware commentedHere is an updated version of both the drupal 5 and 6 version of this patch.
They fix a bug that popped up when used on node locations for a content type with underscores in its machine readable name.
Comment #31
aren cambre commentedOK, I wiped and repatched. I have the patch in #30 and the patches in #434290: Multiple locations on a single gmap and #338740: Display locations as polygons on gmap views. I think it's working as intended, but two issues:
Are the Location and Gmap module maintainers aware of these patches?
Comment #32
mrgoltra commentedsubscribing
Comment #33
agileware commented@Aren:
Thanks for the feedback. It would appear that the maintainers are not aware. There doesn't seem to be much action on the issue queues in general for a while so they are probably tied up with paid work or something. It's hard to find the time for community sometimes.
In regards to your issues:
Comment #34
Chris Einkauf commentedSubscribing
Note to myself: Need gmap polygon patch (#338740: Display locations as polygons on gmap views), multiple locations on single map gmap patch (#434290: Multiple locations on a single gmap), and location patch (#338745: Multiple locations on a single map) for multiple locations to display on a single map.
Comment #35
alxp commentedSubscribing
Comment #36
agileware commentedThe changes to the location module since the patches in #30 means that they no longer apply correctly.
Here are updated patches for the most recent dev versions (currently 2009-Jul-31).
Comment #37
manuj_78 commentedPlease refer http://drupal.org/node/490802#comment-1863446
You can contact bdragon on IRC and ask him to have a look at these patches
Cheers
Comment #38
rooby commentedI have done a lot of work on this (I work for Justin) and there is not really any free time for us to be working on this at the moment so I will do it in my own time.
I hope to get to it pretty soon and fix up a few more details.
Comment #39
rooby commentedComment #40
zoltán balogh commentedsubscribe
Comment #41
spacereactor commentedsubscribe
Comment #42
klonossubscribing...
Comment #43
cbrody commentedsubscribing -- I could do with a patch for the most current RC (6.x-3.1-rc1).
Comment #44
rooby commented6.x-3.1-rc1 is far from the most current version at the moment.
There are a couple of things to get in before a new release (6.x-3.1).
Keep an eye on #664472: [master] Release of Location 6.x-3.1? for the status on this.
Once that new release is out I will make a new version of these patches for it.
Until then, things are being committed reasonably regularly at the moment so if I keep making patches for dev they won't be valid for long.
Comment #45
summit commentedHi Reuben, see that http://drupal.org/node/664472 is done now :), can this patch be committed please.
Thanks a lot already for all your hard work!
greetings, Martijn
Comment #46
rooby commentedIt won't be committed right away.
I haven't looked at this for quite a while so I will need to re-test and look over the patches again (this was quite a while ago so I might have better ways of doing things now).
I also want one of the other maintainers to look over it before it gets committed seeing as I have done a lot of work on the patch.
I am on holiday for two weeks starting tomorrow.
I'll see if I can make some time to re-roll the patches for the current version before I go.
From memory I know there are a couple of outstanding issues with this functionality as a whole, I just can't remember exactly which of the patches are affected. So I will go over it all as soon as I get back.
Marking as needs works because it needs a re-roll.
Comment #47
summit commentedHi Reuben, will test for you the next two weeks if you file a patch against dev before your holidays :)
Thanks for rerolling in advance and enjoy your holidays!
greetings, Martijn
Comment #48
rooby commentedHere is the D6 patch for 6.x-3.1.
I have not had time to even test that it works, it is just a direct re-roll of the existing patch.
I noticed there are definitely things I would like to do a little differently with the patch in terms of code so it will need a bit of work when I get back.
But functionality wise it can still be reviewed so setting to needs review so people test.
Comment #49
rooby commentedOops, here is one that applies with
patch -p0
Comment #50
kbk commentedI've applied patch #49 and the corresponding gmap patch and I get strange behavior when the content type has a CCK Location field (works as expected with only the 'default' Location field). From what I gather, to generate lat/long information for the CCK location field you must use on the 'default' Location map (i.e., there is not a separate google map for CCK Location field.)
I've attached my content type and a screenshot (notice that placing markers in the 'default' Location map places the coordinates in the CCK Location field.) I'm running Drupal 6.16, GMap 6.x-1.1, Location 6.x-3.1, CCK 6.x-2.7
Thanks for all of your work!
Kyle
Comment #51
larowlanHi rooby
I'm keen to help out with this one, can you advise of the current status and what needs to be done.
Happy for you to PM me via contact form
Lee
Comment #52
larowlanPatch at 49 works for me with 6.x-3.1
Comment #53
kbk commented@larowlan, can you be more specific with respect to comment #50? Did you add a CCK location field or were you working with only the default location field? The patch behavior differed between these cases for me.
Comment #54
rooby commented@kbk,
I have not yet tested with cck locations (see #12).
I will test that this weekend when I come back to these patches.
Comment #55
larowlandefault location field sorry
Comment #56
klonos...where are we on this one?
Comment #57
rooby commentedI went through the location RTBC issues last night and I'm going to go through the gmap ones tonight.
Then this weekend I'll come back to this one and get a better patch out for people to test (this time for sure :)).
Comment #58
bdragon commentedLatitude / longitude fields in {location} are NOT the right place to store polygon data. I'd be much happier with this sort of thing if the polygon data was stored in a side table, and the latitude / longitude fields were only used to store the centroid.
It's not http://groups.drupal.org/node/6089 but I would accept supporting a side table.
Comment #59
guillaumeduveausubscribe
Comment #60
nwnolte commentedIt doesn't seem like there has been much work on this in the past two years, and I am having trouble patching Location with this newest patch as well as the Gmap Polygon reroll patch.
I need to implement a map containing the locations of collected specimins. Each node is a species and there are multiple samples collected for each species but I only want the node map to show the location of the current species' locations.
Comment #61
kbk commentedI'm going to take the liberty to quote bdragon and squash this patch. It's not going to be committed without a major rewrite:
< kbk1> Bdragon: Would you commit the "Multiple locations on a single map" patch?
< Bdragon> kbk1: Not as it currently is. For it to be reliable locations an offset column will need to be managed in {location_instance} -- location doesn't guarantee that it returns stuff in the same order currently.
Comment #62
klonos...not having a solid solution *currently* does not mean ditching the whole feature request as "wontfix". It is a perfectly legitimate request AFAICT - we simply didn't manage to implement it yet.
Reuben didn't come back at this though as promised back in #57, so I guess it is safe to assume that he either lost interest in this, found another solution or simply does not have the time. So, unassigning and setting to the latest 7.x-3.x branch where all new features belong (7.x-4.x is abandoned and 7.x-5.x is officially not recommended for use/test on any site). If eventually someone comes up with an accepted solution, this can perhaps be backported to 6.x.