Here is a patch that allows multiple locations of a node to display as a polygon on a gmap view instead of multiple markers.

It allows users to select on the view whether to display markers as markers or polygons (unique settings for page & block).
It allows users to select in the gmap settings to use random colours for the polygons instead of the default colour.

There are also changes to the locpick javascript to allow for selecting multiple locations on a single gmap when you are editing nodes. This is very useful for seeing where all the points are on your polygon and it also means only one gmap has to be rendered instead of one for each location. -> There is a corresponding patch for the location module that goes with this one to make that all work. I will post a link here when I have put it up.

Please try it out and give feedback. It has been quite useful to us.

Comments

agileware’s picture

The patch for the location module that goes with this one to allow you to select multiple locations on a single map is here: #338745: Multiple locations on a single map.

agileware’s picture

For the polygons to work properly in IE you will also have to add

xmlns:v="urn:schemas-microsoft-com:vml"

to the html tag of your pages so it would be something like this:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" lang="<?php print $language ?>" xml:lang="<?php print $language ?>">
aren cambre’s picture

Thank you for this addition. I have a 6.x site where displaying neighborhood boundaries would be very useful, so I would love to see this get to GMap 6.x.

bomarmonk’s picture

Will this make it into the 5.x version of module? I'm eventually upgrading to Drupal 6, but in the meantime...

aren cambre’s picture

Status: Needs review » Active

I noticed the following in the release notes:

  • 1.0 references "Allow using references to styles in lines / polys."
  • "Document extramarkerevents and the new clickableshapes behavior flags. Add shape clickability."

Does this mean shape/polygon support is forthcoming?

Changed to "needs work" status since this probably needs to go into 6.x first, so existing patch needs modification.

aren cambre’s picture

Version: 5.x-1.0-rc2 » 6.x-1.x-dev
Status: Active » Needs work

Changing status as per #5.

aren cambre’s picture

Issue tags: +location polygons

(adding tag)

agileware’s picture

I think this patch would be best split into two patches as it does two very different things.

One patch would be for the functionality that allows selecting multiple locations on a single map and one would be for displaying locations as polygons on a gmap view.

This would be much more logical and better for the module maintainers too.

I'll have a look at this when I get time but someone else is welcome to do it in the meantime if they want.

agileware’s picture

Status: Needs work » Patch (to be ported)
StatusFileSize
new16.45 KB

I have now split this patch into two.

The part that handles having multiple locations on a single map can be found here - #434290: Multiple locations on a single gmap.

This patch now only handles displaying locations as polygons on a gmap view.

This patch is for 5.x-1.1-rc1.

I will work on d6 versions of these patches as I get time over the next week.

yesct’s picture

tagging

aren cambre’s picture

Has this progressed any?

agileware’s picture

Assigned: Unassigned » agileware

Going to start working on a patch for this for drupal 6 now.

agileware’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new15.92 KB

Here is a patch for Drupal 6.

The patch is for 6.x-1.x-dev.
It will apply to 6.x-1.1-rc1 with offsets.
It will apply along side the multiple locations on a single map patch in #434290: Multiple locations on a single gmap

In the style setting of the view (where you select gmap view), the marker handling select field now has an option for polygons.
The polygons are made from points grouped by the grouping field you select on this form, for example nid.
You also get the option to select whether each group (each group will be one polygon) displays on a different map (which is how gmap normally does groupings) or on the same map.

I have tested with location views.

I have included gmap.views_default.inc with two (disabled) default views. One that displays node locations on a map as a polygon per node and one that displays user locations on a map as a polygon per user.
***Note: In my testing I cannot get views to pick up these default views. I can't see what i'm doing wrong so if anyone can tell me it would be greatly appreciated. You can copy and paste the code from the gmap.views_default.inc file and import the views using the normal views import.

Nodes/users with less than 3 locations will not display on the map.

Please test this and let me know if there are any bugs or if you request more functionality.

Thanks.

aren cambre’s picture

Not sure what to make of this:

$ patch gmap_plugin_style_gmap.inc gmap_views_polygons_6x-1x.patch
patching file gmap_plugin_style_gmap.inc
patching file gmap.views_default.inc
can't find file to patch at input line 470
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff -rupN gmap_old/js/gmap_shapes.js gmap/js/gmap_shapes.js
|--- gmap_old/js/gmap_shapes.js 2009-04-07 07:23:17.000000000 +1000
|+++ js/gmap_shapes.js  2009-06-04 12:12:02.000000000 +1000
--------------------------
File to patch: gmap_shapes.js
gmap_shapes.js: No such file or directory
Skip this patch? [y] n

I guess it's looking for gmap_old/js/gmap_shapes.js? The file appears to be at js/gmap_shapes.js, so maybe the gmap_old threw it off? Or maybe my lack of knowledge of this system is throwing me for a loop. ;-)

agileware’s picture

The gmap_old stuff doesn't matter. it will look for js/gmap_shapes.js

The patch will apply at -p 0

I'd say the problem is that the module has changed with the new dev version and I will have to reroll the patch for the new dev.

ibagur’s picture

I've applied this patch at -p 0, together with http://drupal.org/node/434290 and http://drupal.org/node/338745 and they work flawlessly. These guys also have a nice demo site on http://demo.agileware.net/ anyone can access and play around. I think these patches should be added to the GMap and Location modules HEAD. Great work!

yesct’s picture

agileware’s picture

StatusFileSize
new15.93 KB

The patch in #13 has a bug that means the default value for the 'Polygon Grouping' option is not remembered after you change it and go back to edit it again.

I have fixed that bug with this patch.

It still applies to 6.x-1.x-dev (2009-Jun-09).

agileware’s picture

StatusFileSize
new16.31 KB

Here is a new version of the patch that has the default views problem fixed (I mentioned the problem in #13). I forgot to fix it in the #18 patch.

So the default views I have included in the gmap.views_default.inc file will now be usable.

The patch will still apply along side the patch in #434290: Multiple locations on a single gmap but if you apply the single map patch first this patch will apply with an offset.

aren cambre’s picture

Small errors: on the Polygon grouping dropdown, there is a period at the end of each selection, and you used it's (contraction of "it is") where you probably meant its (possessive).

Bigger problems:

"Items to display" doesn't work right. It regulates the number of points, not the number of polygons. Suppose you have 2 nodes, the first node has 14 points, and the "Items to display" is left at the default value of 10. All the map shows is the first 10 points of the 14-sided polygon. This field only has meaning if set to Unlimited.

Polygons get merged. My view has two nodes displaying. All points get merged into one polygon, and if I click on the polygon, I get the information for the second node.

No way to select color. Without this, it's difficult to distinguish between nodes.

This patch is really exciting and I hope it eventually makes its way into the module. Since I have this working now in my test environment, I am more easily able to help with further testing.

aren cambre’s picture

Tag is missing a comma.

yesct’s picture

adding back tag (see location module faq issue which lists common location tags). Tag makes more sense when searching across multiple projects. http://drupal.org/project/issues/search?text=&projects=&assigned=&submit...

redijedi’s picture

subscribing

agileware’s picture

@Aren:

Thanks for the feedback:
*The items that display bug is know to me already. I just hadn't got around to it yet.
*The polygons being merged is a bit strange, I have not experienced that before. If I can't reproduct it and you aren't using one of the default views provided I might have to get you to post a txt file with the view export.
*For the times I have used colour, I have added a colour field to my node (using the colorpicker module (or just a text field). I then added code to use that field for the colour of the polygon.
I think that colour selection itself should not be a part of these patches, but I will add a setting so that you can select a field from your view to use as the polygons colour and if the field is empty it uses the default.

I plan to address these issues within the next week before I go on holiday.

Chris Einkauf’s picture

Subscribing

alxp’s picture

Subscribing

dadderley’s picture

Subscribing

baobab’s picture

sorry, but for the v5.x-1.1-rc1 patch I've got the issue similar to this one (http://drupal.org/node/303066) - "Fatal error: Call to undefined function update_sql()"

How to avoid it?

thnx

-v

agileware’s picture

If you replace hook install with:

function gmap_install() {
  db_query("ALTER TABLE {view_view} ADD COLUMN (
                  page_gmap_marker_type varchar(20) NOT NULL DEFAULT 'marker',
                  block_gmap_marker_type varchar(20) NOT NULL DEFAULT 'marker')");
}

it should fix it.

I will re-roll the patch as soon as I get a chance.

- Also, as a note to everyone else, this only affects the drupal 5 patch.

rooby’s picture

Assigned: agileware » rooby

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

aren cambre’s picture

Thank you. I look forward to these enhancements!

redben’s picture

subscribing

ccshannon’s picture

subscribing

klonos’s picture

subscribing...

tnfno’s picture

subscribing... also willing to co-finance the development, I need polygons !

artemtk’s picture

Title: Display locations as polygons on gmap views » Cannot Patch
Category: feature » support
Status: Needs review » Active

Hello,
I am not really sure what I am doing wrong. I have downloaded the patch (gmap_views_polyons.patch) from the top of this page. I have run the following 'patch -p0 < gmap_views_polyons.patch'. I get the following message:

$ patch -p0 < gmap_views_polyons.patch
patching file gmap.install
Hunk #1 succeeded at 85 with fuzz 1 (offset 9 lines).
patching file gmap.module
Hunk #1 succeeded at 41 (offset 6 lines).
Hunk #2 succeeded at 134 with fuzz 2 (offset 35 lines).
Hunk #3 succeeded at 578 (offset -278 lines).
Hunk #4 succeeded at 634 (offset -278 lines).
Hunk #5 succeeded at 725 (offset -277 lines).
can't find file to patch at input line 96
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -rupN gmap_current/gmap_views.module gmap_new/gmap_views.module
|--- gmap_current/gmap_views.module 2008-11-25 11:56:36.000000000 +1100
|+++ gmap_views.module 2008-11-25 11:57:45.000000000 +1100
--------------------------
File to patch:

What am I doing wrong? The gmap module does not have gmap_views.module file...

Thank you,
-A

klonos’s picture

Title: Cannot Patch » Display locations as polygons on gmap views
Category: support » feature
Status: Active » Needs review

Please do not change issue titles to meaningless things. This makes it hard for others to locate them and possibly causes others to report duplicates. The title is there to provide a short description of the whole issue and not to reflect problems of each post made.

...changing back as it was.

klonos’s picture

Status: Needs review » Needs work

The patch from #19 was created a year ago. This makes it almost certain that it will not apply cleanly to latest versions. You'll need to either try to apply it manually or wait until somebody re-rolls the patch against the latest stable or dev version.

cmcintosh’s picture

Looks like there is some need for this, I need it myself for my sales staff to setup territories. A couple things im trying to do is be able to handle areas or just the normal points to this end for one of the things I am doing is creating some new views handlers. Hopefully to the point that I can display several areas (polygons) on one map.

cmcintosh’s picture

whats weird is that it looks like the current stable has some sort of poly handling built in, looking at the js files you have an experimental poly.js file. Has anyone used this as of yet?

Seems like there are some substantial changes from the views plugin that was in gmap a year ago and the one in the stable now. SO there will be some research needed for that.

rooby’s picture

There have been a few things committed recently which means the patches don't apply properly.

There are more commits to come so at some point I will re-roll the patches.

If anyone wants to re-roll them in the meantime feel free.

neofit’s picture

Hello, the patch given in #19, as well as the one in #434290: Multiple locations on a single gmap fail with the current 6-dev version. Has anyone been working on an update on these patches?

zeezack’s picture

Title: Display locations as polygons on gmap views » Get gmap views to work inside a fancybox
Assigned: rooby » zeezack
Category: feature » support
Priority: Normal » Critical

I have got the gmap mod working, but when I load the page inside a fancybox the map does not work, it tries to reload the page but just displays a white page?

I can not see what is going wrong. Does anyone here have any insight or can help?

klonos’s picture

Assigned: zeezack » Unassigned
Priority: Critical » Normal

@zeezack: once again you hijacked an issue for a personal support request and assigned yourself to the issue. Please try to refrain from doing so. Start your own issues and assign yourself to them only if you are prepared to work on them.

This time you've also set its priority to 'critical'. Please see the links bellow the 'Priority' and 'Status' drop-down boxes and you'll find for yourself that ...the more-urgent priority is unlikely to give you better support

Please have a look here on how to report issues: http://drupal.org/node/73179

thanx

klonos’s picture

Title: Get gmap views to work inside a fancybox » Display locations as polygons on gmap views
Category: support » feature
agileware’s picture

Re the status of these patches:

See rooby's comments here - #338745-44: Multiple locations on a single map

A new version of these patches won't be too far away, after the next stable releases of location & gmap come out.

larowlan’s picture

StatusFileSize
new13.94 KB

Here's a re-roll against gmap 6.x-1.1 that applies without failing
still testing

larowlan’s picture

Status: Needs work » Needs review

Patch at 47 works with gmap 6.x-1.1 and location 6.x-3.1 and patches found here #338745: Multiple locations on a single map and here #434290: Multiple locations on a single gmap (these aren't needed but make the node entry form a lot nicer)

larowlan’s picture

Note that the changes at comment 2 didn't interact well with vertical-tabs module for some reason on FF3.6.

rooby’s picture

Thanks for the re-roll and testing, I forgot I'd only done the single map ones.
I'll spend some time on these on the weekend.

larowlan’s picture

No worries, now working on getting polygon on node view too for multiple locations (without views), theme_gmap is so powerful!.

teckcrew1’s picture

I am also interested to see how your doing on this patch. Looking for a way to add polygons to gmaps with locations.

teckcrew1’s picture

StatusFileSize
new443.99 KB

hello,

I can see where this addition would be very helpful if you want to display a polygon on a view that is made up of DIFFERENT nodes. But what if all my points are on the same node, Would this still work for me? I installed the patch and noticed this is the way it is working. Is that correct?

Here is my use case:

I have a custom content type called neighborhood. Each neighborhood has 1 map, that has a polygon drawn on it which represents the neighborhood boundry. I will not ever need the polygon to be created from points from multiple or different nodes. They will always come from the same node.

In fact, in the simplest form what would work perfect for my situation is to duplicate the build a gmap macro page found at: map/macro. See attached screenshot.

I want the user to be able to draw the polygon directly on the map, like they can do on the build a gmap macro page. The other posts I have seen so far require Locations fields be set up. I don't necessarily need (or want) individual locations setup. I just want to mirror build a gmap macro exactly.

Is there a way to do this without alot of custom coding?

Thanks in advance for your help!

rooby’s picture

At this stage what this does is a polygon per node.

So each node has three or more markers on it and when using this patch you can make your view display the markers as a polygon instead of markers. So you will get one polygon per node.
That's pretty much the only way it works at this stage.

And the other patches for multiple locations on a single gmap just help make it easier to place the multiple markers that make up the vertices of the polygon.

None of the patches relating to this issue or the multiple location on a single map cover your use case of drawing polygons on the location selection map. That would be a new feature request, which would require work on the location & gmap modules.
It would probably be best as an extension of the multiple locations on a single map patches.
This is pretty much just a bit of thinking out loud at the moment though as I don't have time to get back to these patches and think about it properly until next week.

teckcrew1’s picture

Thanks rooby for your feedback.

I found a solution that so far looks very promising so far. Open Layers is much more powerful then I had originally thought, and it draws polygons the way I want just as I wanted gmaps to do.

The demo that really helped me was this one: http://yadadrop.com/drupal-video/gis-mapping-drupal-openlayers-geo

Anyone else who needs to put polygons on maps might want to try this out. I'll post the final solution after I get it all working.

pacome’s picture

subscribing

[plus] : I'm looking for the same function, but with line.
Does someone knows if this patch could be a starting point for it ?

Regards

P-

klonos’s picture

...well a line is kinda polygon with no corners (only two points) ;)

So, I guess lines will be possible, but do you care to share with us why you need lines? I mean can you please give us a real life use case that utilizes lines?

pacome’s picture

Hi Klonos,

thanks for your reply.
In my case I want to use lines to visualy describe the itinerary of a node, from a location to another.
Like a gps tracker, but based on "human" adresses (location module) rather than gps datas (tracker module).

More generaly, I think it could be usefull for any kind of schematic itinerary and travel map (bird migration, flights, long distance travels, historical maps etc..).
What's your opinion on it ?

regards
-p

klonos’s picture

When I read your post in #56 I was left under the impression that you were after single, individual, two-point lines (a point for start and one for an end). You were talking about successive points forming a route though! I think this is a very nice feature request and that it deserves an issue of its own. Unless of course someone here thinks that it will be covered here. I am sure that this issue here will help people that need area data (like square units of the polygon for example), but I don't know for sure if it will do lines and distance units.

As stated in #54:

At this stage what this does is a polygon per node.

So each node has three or more markers on it...

So, the way I see it this works by setting *at least* 3 points and the first and last are joined to form a polygon. Lines should not behave this way (they can have only two points and their start & end don't necessarily get joined + they might be criss-crossed in different points). Anyways, the more suitable person to answer all these is Reuben of course, so...

@rooby: did you manage to find some time for this? Do you think that lines will/should be covered here or should we open a new issue for it?

bdragon’s picture

Reroll incoming.

bdragon’s picture

Status: Needs review » Needs work
StatusFileSize
new15.84 KB

Here's a reroll with some changes:
-- Merged the common parts of the loop. (It's still too hard to read that function, though.)
-- Redid shape clicking in a more acceptable (not perfect yet though) way -- it supports all the stuff markers does. This part may go in separately since it's generally useful. (I am still trying to decide whether or not to set up default handlers for shapes like this, I might break existing code... If it does go in, it means the clickableshapes behavior should be removed. I might want to evaluate setting the overlay click handlers up on the map level though to reduce event overhead significantly first, though...)
-- Added rmt capability to match the general gmap views rmt capability I brought in earlier today.

I'm not really fond of this code, but then again I'm not fond of the render() in general for gmap_plugin_style_gmap().

pacome’s picture

hello all

just to know if you think i should open a new issue for lines, (#56 to #59) ?

I don't know if it can interest other people, but i hope so : i'm not able to solve that alone :)

Best regards
-P-

klonos’s picture

I guess it does make sense for ...say displaying bus routes and things like such. If you don't open a separate issue for it, I think I will.

pacome’s picture

here is the new issue :
Display lines between locations on gmap views / http://drupal.org/node/970724

klonos’s picture

Thanx von-p. Lets take it there then ;)

tangent’s picture

Subscribing

mry4n’s picture

Subscribing

dmattie’s picture

A newbie question: I have the latest version of gmap 6.x.1.1, and this feature doesn't seem to be available. I need to "Use polygon as points" in the style options of the view definition.

This patch seems to be for the dev version only, and we need to move forward. Can anyone help/offer advice? Am I missing something? Does the feature exist in the lasted version?

Failing that:

Our views module has been upgraded to 6.x-2.16, and our clickable polygones have stopped working with this error:
Notice: Undefined property: views_plugin_row_fields::$field_alias in views_plugin_row->render()

I really appreciate any help
thanks.

nwnolte’s picture

Since Multiple locations on a single map has been closed, I assume that both this patch as well as Multiple locations on a single Gmap are no longer being supported as they functionally rely on each other.

podarok’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs work » Closed (won't fix)

due to #69 - closed
feel free to open against latest major dev versions with ready to review patches

thanks to all