Possible to show user locations on map but limit public view to city for user privacy?
lsabug - March 25, 2007 - 23:34
| Project: | GMap Module |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I've got gmap/gmap_location.module, location.module enabled and functioning. I want to collect user addresses but would only like the gmap_location.module to display the user location up to the city zoom and not specifically to the user's address for privacy. Is there a way to make the gmap_location.module ignore the address field when generating the map and markers?
Thanks.
Lsabug

#1
The location data is a specific longitude and latitude, meaning an exact address or physical location. Whether it is input via an address field or pinpointed with a map, the output is the same. There aren't levels of accuracy in the data, just levels of zoom. The best way to approach your problem is to limit the zooming level on a map.
One idea: Write a GMap View that pulls in all the users data. Set a filter to search via City. In the Argument Handling area include a gmap_macro setting that enables no-dragging and auto-zoom and hides the map controls. Set an if statement that loads the gmap_macro if the user doesn't have appropriate access levels. I haven't tried this, but in theory it should work
- Look at bdragon's comment (http://drupal.org/node/99854#comment-212727) for more info about gmap_macro settings.
- Example gmap_macro:
$view->gmap_macro = '[gmap |id=your_map |width=100% |height=400px |control=None |behavior=+autozoom +nodrag]';Autozoom doesn't seem to zoom-in that close, so this may or may not suffice. Also, I'm not aware how to adjust the autozoom settings, but I suppose it would be a js modification.
And another: If your users are spread across a handful of cities that don't change, then you can build specific City GMap Views (same as above sans exposed filter) that include more tailored gmap_macros--specific zoom level, specific focal point, etc. You'll still need to determine the user access level before loading a macro. And, if you Provide Menu and Provide Menu as Tabs, you'll have a nifty tabbed map that jumps between, say, the US, Chicago, New York, Portland, and Ann Arbor--making sure, of course, you set the URL's correctly (views/map, views/map/Portland, views/map/NewYork, etc...)
Again, these are work-around solutions to your problem. Actually limiting the zoom based on access levels is way beyond my scope.
#2
Wow, thank you so much meximese for the detailed explaination and options! I will definitely look into limiting the zoom option.
THis is great!
Lsabug
#3
Though even with zoom set low, a quick look at the page source would give the full lat/long...
\"\x3eScott\x3c/a\x3e", "latitude": "45.665151", "longitude": "-123.765625", "markername": "drupal", "tooltip": "Scott" }#4
Didn't realize that, thanks for pointing this out.
#5
Good point landowneyes, that also didn't occur to me. I suppose I've never had the need to limit access to mapped points.
Lsabug, I can't really think of a good solution to this problem... unless of course you could truncate the lat/long to an integer for public viewers... which would probably leave you with a bunch of users at one spot... not pretty. Or generate an image of the map (say, once a day) and load that image instead of an actual GMap. (again, how you'd do this is beyond me, but I'm sure it could be done.)
Can I ask what this map view is for? What's your purpose of showing users in map at only a city level? Are you looking to demonstrate that there are indeed users of n-number in x-area?
It might be best to examine other ways of presenting this info.
Here's my dream: Mapping out areas (like a zipcode or voting ward) with Views integration such that when you click on, say, a polygon highlighted area, the Views info appears. I'm guessing in this case the Views info would be a summary count of number of users in that area, or registered voters in a ward. Going on that idea, why not allow for simple info to be placed directly on the map (within or above a .png) instead of requiring a popup? I don't know any way method to accomplish this, but I'll start looking and trying!
#6
maybe it's doable via location zip code. Location module has some zipcode database. Instead using of lat/long zipcode may solve your problem.
#7
Hiya meximese and thanks for replying.
I want to be able to show where my members are located down to the city but not so specific as address. The thing with location.module which I also have installed is that I want to have a list of user addresses and zips but these are stored I believe simulataneously within the gmap.module although I'm not exactly sure how it works, except I think I read they do share the same tables.
Basically, I'm just trying to maintain my members privacy as far as location. I know that I didn't like being able to see my address on google maps.
Lsabug
#8
Okay, it sounds like you'll probably want to make a Views list of the users per city. You can create a View that lists all users that share the same zipcode, or city. This, however, will put it all into a list or table or display profiles... etc. Look at Views handbook pages and the views module for more reference
BETTER YET! It just occurred to me that there is a way to include a view into a gmap popup. I literally just ran a 5 minute test, creating a new CCK with a views_field, and two new views. I can't really explain much right now as I'm at work and really shouldn't be doing this, but the skinny is this:
Again, I really only tested this in about 5 minutes with one map and two brand new views. The data doesn't correctly show, but it works to a degree: (http://hawkerandshill.com/gmapper/users-by-city). The reason for all the 0.00 is that I added a Location by Proximity filter by Postal Code and none of the previous test data I entered has zipcode entries. hah.
The best part about this is that it opens up another level of data mapping... and is also a step, I can only suppose, towards my previous dream of doing summary counts per gmap marker. Now all you have to do is make an extra large marker that covers a larger region, say a city, and you'll have a spiffy map of users per area that leads to a fuller page of all users in that area...
alright, I gotta get back to work.
#9
Wowza, meximese, I totally dig what you did, even if I don't totally understand it
: )
I'm going to read over your explaination and try it on my development site.
Quick question, do you have location.module loaded or is this all through gmap? So the user would add their location to the map rather than via location.module? I seem to be under the impression that you can enter you information into the location form and this information will in turn be posted on the map for each user.
Thanks again, will be back!
lsabug
#10
Yes, you should be using the location modules as well as gmap modules. Someone correct me if I'm wrong, but in a very basic sense, Location module handles location data and some basic geocoding functions. GMap modules taps into the Location API to grab the location data and in turn allows it to be processed into maps. That is where the beauty of the two functions lies: Mapping nodes that have location data attached.
I think when you are referring to the "the map" you are referring to the User Locations map that comes packaged with either Location or GMap module. This map does show User Locations based on their profiles, but to create a map with more specific information you'll want to create a GMap Views map. To do this you'll need to install at least the Gmap, Gmap Locations, Gmap Views Integration, Location, and Location Views modules. With these installed you have the capability of creating a map that generates markers based on Views queries.
Here's a basic rundown of creating a Views Gmap:
Now, onto embedding Views into a GMap View. In that case you want to show, on a map, all the users in a specific city without revealing their specific longitude/latitudes. This can be accomplished with two Views: One that lists all the users per city and a second that maps those cities.
We're basically doing the same thing as above, but adding another View as well as another content type. The extra content type is kind of a like a container for your users-per-city list. These CCK nodes will contain an embedded View using the Viewfield module. Then the container nodes will be plotted on a map, their pop-ups containing the wanted info.
I have a simple version working (http://www.hawkerandshill.com/gmapper/users-by-city) that shows one marker with a view in the popup. The title of the URL is misleading as this has nothing to do with users, but instead fake parks I've mapped in Portland... but it works. Now, I haven't tried this with anything other than embedded List Views, but it seems like other view types could work. However, I'm not sure you would really want a lists of Full Nodes in a pop-up as that would move your map around quite a bit. One thing that could work is a summary count of users in that area that then leads to a full list of users per city, but, again, I haven't tried that at all.
Oh yeah, the caveat: at this point you have to add a node per city that contains little more than a list. It's definitely not the best solution, nor is it truly automatic, but it solves a problem. If you really wrap your head around it, there's probably a way to utilize Views and enough taxonomy terms or other data to automatically create a container node... maybe not.
sleep for now. dream of maps and monsters. plot my dreams later.
vinh!
#11
sorry if this is a dumb question (and off topic), but: how do you create the views of user lists with location fields? on the views edit page/field options i only get node:author name (which gives me the node locations, not the users). how do you get a plain "user" field? do you work with nodeprofiles/usernodes and set locations there? even with usernode installed i get an error, because gmap.module needs "latitude" and not "userlocation: latitude". any help would be great...
#12
http://drupal.org/node/136199 marked duplicate.
#13
this is really interesting! If anyone finds an automated way of generating this, please post!