Clickable Polygons

Events happening in the community are now at Drupal community events on www.drupal.org.
seanberto's picture

Anyone had any luck adding clickable polygons to a Google map in Drupal?

Use case:

Create a node type that allows you to enter the boundaries of a polygon. Then, display those polygons a Google map, such that someone can click on a polygon to be taken to a specific node.

Thanks,
S

Comments

here's an example of an

seanberto's picture

here's an example of an openlayers site doing something similar to what I'm talking about:

http://firecenter.berkeley.edu/fhsz/

-s

imho, the above linked site

kfall's picture

imho, the above linked site likely only displays polygons via a custom tile-server as bitmap, not as vector.
Probably they determine the lat/long of the click, then use spatial querying in the back-end to figure out which polygon the click was in.

It'd take too much browser overhead to plot polys with that level of detail.

However, for real inspiration, check out walkscore.com -- they use simplified neighborhood polygons in city-level maps with mouse-over to load content (node). http://www.walkscore.com/rankings/Seattle

For your example site, just need to use a spatial-enabled db in the back (mysql spatial extension or other db supporting spatial queries).

If you're really concerned

aj045's picture

If you're really concerned with polygonal overlay, consider doing a server side render of the map. The overlays at the link you supplied resemble a pixel-by-pixel rendering, which as karl said, suffers too much browser over head to render on the client machine.

Two Parts

andremolnar's picture

There are two parts to this problem.

Part 1: Draw the polygon. This is easy enough to do via the google maps api - and modules like gmap et al.

Part 2: Determine if the polygon was clicked. Well this is much easier to do now than it was in the past: http://googlemapsapi.blogspot.com/2007/09/v288-clickable-polylines-polyg...

Part 2b: Take the user to the desired destination.

In the past you had to write your own code to determine if a click was within the polygon boundaries - see the algorithm described in the link above.

andre

and not just going to a node but finding contacts within area

petednz's picture

Cross posting from http://groups.drupal.org/node/13581

And a related goal is to be able to click on one or several contiguous polygons and have that output a list of those polygons which in turn can output the coordinates of the perimeter - which can they be thrown at CRM database and query it to identify all contacts whose coordinates are within the perimeter. I have a working model here but it was not produced on open source but shows what is possible.

pete davis : fuzion : advocacy + strategy + communication

pete davis : fuzion : connect + campaign + communicate

Location and Mapping

Group organizers

Group categories

Wiki type

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: