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

meximese@drupal.org - March 26, 2007 - 10:42

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

lsabug - March 26, 2007 - 17:27

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

Scott Falconer - March 27, 2007 - 05:51

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

lsabug - March 27, 2007 - 15:02

Didn't realize that, thanks for pointing this out.

#5

meximese@drupal.org - March 27, 2007 - 23:36

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

Nemo@groups.dru... - March 28, 2007 - 10:21

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

lsabug - March 28, 2007 - 17:13

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

meximese@drupal.org - March 28, 2007 - 20:54

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:

  1. Create a content type that basically acts as an envelope for Users by City. Make sure to add locative properties to this as well as a View Field.
  2. Populate one of those Users By City CCK's and name it Users in CITY-NAME. Find the city on the map and choose a point to represent that area. Make sure to also choose a view_field view, in your case, Users that share the same City.
  3. Make a second view (assuming you already made the above "Users in a City" view) that is a Gmap View of the Users by City CCK. List all those node types on the map.
  4. View the map and you'll see a point per city. Click on that point and the pop-up displays the Users in that City via the embedded views. You can limit the number of responses in Views or do a number of other things.

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

lsabug - March 28, 2007 - 22:25

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

meximese@drupal.org - March 29, 2007 - 10:30

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:

  1. Install the necessary modules and enter a Google Maps API key in the appropriate places. You'll need to enter the same key for both the GMap and Location modules.
  2. Create or edit a content type and add locative properties to node form. Depending on settings in both GMap and Location, you can allow users to pinpoint a location via Address, City, State and Zipcode, or by actively choosing one on a map. Populate a few nodes this content type. (Lsabug, in your case you'll just want to make sure your users can enter or choose a location, probably via Profiles.)
  3. Create a list View that shows the User names or node types with locative properties. Make sure to enable either a Page or Block view for this Views List. Also make sure to include Location Longitude and Location Latitude in the Fields settings.
  4. If the View works you'll get a list of node types or users in a page or block. Great. Now edit that View and change the View Type from List View to GMap View. Make sure you have a Page View and have a valid URL for this test.
  5. Now if the View works you'll get a Google Map with markers representing the nodes called in the Views query. Click on a marker and you'll get a popup that lists whatever fields you defined in the View... like the Title/User and Longitude and Latitude.

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.

  1. Create a Views list of users in a city by choosing Profiles City as a filter.
  2. Add an extra content type named "Users by City," making sure to add locative properties to this content type
  3. Add a Viewfield field to the content type, adjust your settings appropriately.
  4. Populate some nodes of this type. You might, for example, title one "Portland, Oregon" and for the location pinpoint the center of Portland on the map. When selecting which view to embed, choose the one that generates a list of users per city.
  5. Create a GMap View that plots the "Users by City" content types as a map. (refer to the steps above to make a gmap view)
  6. View your GMap page. If everything works you'll have a map with a marker on it over Portland, OR. Click on the marker and a pop-up revealing a list of, say, the 10 newest users in that city will appear. Follow the link (if it exists) and you'll get a "Users by City" node that lists all the users in that city; in this case Portland, Oregon.

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

ju.ri - March 29, 2007 - 21:49

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

bdragon - June 30, 2008 - 23:26

http://drupal.org/node/136199 marked duplicate.

#13

YesCT - October 27, 2008 - 08:16

this is really interesting! If anyone finds an automated way of generating this, please post!

 
 

Drupal is a registered trademark of Dries Buytaert.