I'm using GMap to help users find other people in their area. But I'd like to let users have some privacy only making their city and zip code available in the map, but still have the full address in the database for mailing purposes. How can I do this? The position of the pin on the map should also be only based on city and zip, as obviously it could be pretty precise as to location.

For example, let's say the president registers on our site. He enters his full address, 1600 Pennsylvania Ave NW, Washington D.C., DC 20500. An administrator can now look that up and mail him our newsletter.

Another user in the D.C. area is looking for people to meet up with. They look and see a pin on the map for a user POTUS. The click on the pin and it only displays a partial address, Washington D.C., DC 20500. And the pin's location isn't exact, so the user can't tell from its placement the exact address of POTUS. But it is enough that the user knows they are nearby, so they send a user to user message to get in touch.

Any solutions for non-exact pin locations would be fine. If it was slightly randomized. Or perhaps all pins in a zip-code are grouped into one with a link for "# users in the 20500 area" which takes the user to a full list.

If this can be done with something other than GMap, that is fine.

2 Answers 2


I had a similar problem, and this is how I solved it:

  1. Add another 'location' field to you content type; call it, e.g., 'public user location'.
  2. Build up your custom module, and in the hook_form_alter() implementation, hide the new location field, so the user cant edit it.
  3. Now you need to get the 'non-exact' location for the first location; I do this with a Google geocode.

It's up to you to do it via JavaScript when the first location is set (the way im doing it), or to do the geolocation when the form is submitted to 'manually' add the 'non-exact' location.

If you use a geocode on the partial address, Google Geocode will give you the coordinates in the middle of the area you searched.

Please note that, for more specific geocoding, you could even use the Geonames API.

If you choose the second way (create the 'non-exact' location when the form is submitted), maybe this can help you about the location creation: Creating nodes programmatically in Drupal (including cck and location fields).

As side note, I am not using the Gmap module anymore because my needs were a bit complex and were not fit by this module; if you'll find some trouble, I recommend you building your own small module using Google API v3.

This will let you, for example, show the 'public location' in the map with a circle around, as Google Latitude does.


That pin on the map is going to be the center (usually geometric center) of the zip code (with a few exceptions, such as a zip code that only refers to a single building).

Or perhaps all pins in a zip-code are grouped into one with a link for "# users in the 20500 area" which takes the user to a full list.

This is a better solution than putting 20 pins all on top of each other at the center of 20500 zip code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.