Mapping multiple nodes using only zip / postal code

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

We need to map multiple event nodes that will only have a zip / postal code as location data. During my initial testing, all the icons are in the exact same location, since a zip code will always return the exact same coordinates. So, you can only access the gmap popup for the icon that is on the top of the stack. I have tried all of the various cluster management libraries to see if they will solve this problem, and I have yet to find a solution.

Has anyone solved anything similar?

My only thought is to adjust ever so slight the coordinates each time a new node in a specific zip code is submitted, so that the nodes are technically not in the exact same location.

Comments

Not sure if this helps?

iparsin's picture

You may find this helpful, I want to force users to create a node with the limited level of city/state/country to show on map. Successfully get the balloon pops up with multiple nodes that have the same location. I used Jef Poskanzer's Clusterer, with modification the clusterer_marker.js file (please follow http://drupal.org/node/329281 "#24"). So, at view filter your event node, and add fields as you want. I still do not know how to get rid of tiny markers in front of each node inside the balloon though.

thanks, I tried that

justageek's picture

Thanks, I've tried the various clustering solutions, and they do help for crowded maps, but my problem isn't a crowded map. Even with clustering, if 2 nodes have the exact same coordinates, then the markers are stacked on top of each other even as you zoom in as much as possible, so that you can only access one node on the map. I believe that the coordinates themselves have to be altered slightly for each node in the database, but I could be wrong, I just can't find another solution.

To recap, if I put in 2 or more nodes using only zip / postal code as the location, then all nodes are geocoded to the exact same spot on the map, and you can only access one node by clicking on a marker.

I guess I could somehow intercept the json that is used to draw the map and adjust the coordinates there, I'm not sure how easy that would be.

What modules are you using?

apperceptions's picture

Your idea about using small perturbations seems reasonable. What modules are you using to create your maps? location and gmap? your own v3 based mod? I'm looking for the place where zip codes are geocoded, as that would be the place to apply, and perhaps save, the modified location.

Another parameter to consider: how far from a given zip should points be allowed (e.g., anywhere in a 5 mile circle from the geocoded zip). Looked at another way: how far in do you need to zoom in order to see different points.

Here is a small (deprecated) version 2 example that could also be extended to a location/gmap-based Drupal site.

http://code.google.com/apis/maps/documentation/javascript/v2/examples/ma...

Note that points move each time map is redrawn. This makes sense, given the uncertainty of the actual location. If you want to store a single fixed point for each node, you could do this during node save using hook_nodapi. I can elaborate if I know what specific mods you are using.

2 options

iparsin's picture

@justageek

  1. I confirm that clusterer is working(must follow the patch), and what I want is not cleaning up crowded markers, but instead to group nodes that have the same location in one marker. Here is what I have...a pet node type with cck location allows city, state, country. @view I do not have nodereference, argument, relationship, then filters by pet node type , and add any fields I like from that node type. Style to Gmap. So, when click on marker, one balloon will show multiple nodes from that marker(location). I am not sure where I miss to tell you, but I also used to get one result as you do. So, I am guessing clusterer is the factor because I toggle back to use "No manager (use GMap API directly)", only one result show up in the balloon.

  2. I have seen another approaches to shift the markers slightly apart when same location occurs. You definitely can do that way, just consider how you want to present it. For my project, I want to keep markers clean and want to see the marker as a container to hold nodes, so I did not try this approach.

Good luck,
iparsin

thanks for the help

justageek's picture

I'm using the latest gmap and location modules as-is, no mods or custom code at this time. We do want to use a clustering approach as well when the map is at a high level, i.e. the entire US, but as the user drills down into the map, at some level we would like to break up the cluster, so that the user can click individual markers and get the event details. I think I'm going to have to do some sort of post-processing when a node is saved to adjust the coordinates ever so slightly, but I don't know much about decimal versions of latitude and longitude to understand the impact of my minor changes. My manual test, where I'm adjusting the right most decimal value by 1, seems to really move the marker a long way. So, if the coordinate is

32.1234

and I make it

32.1235

It seems to have a huge affect. I wonder if it is viable to make it

32.12341

I'm not sure that accuracy would be stored in the database.

Anyway, thanks for the ideas.

Location and Mapping

Group organizers

Group categories

Wiki type

Group notifications

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