Just a location map for each user

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
suffering drupal's picture

Hello all.

Is it possible just to add a map to a user page?

Even after 2 years of struggling, I still feel like a newbie, as I say in all my posts, and I have been trying for myself for some weeks now (few spare hours a week) and I am about to give up on this AND on Drupal.
How come it is not possible to find a step by step explanation or even any reference to something essential and apparently simple like this?
For the moment I have the impression that users dispose of a map only for INPUT but NOT for OUTPUT????

User locations (map/user) is ok, but where to go to make a clone that filters out per user? It's not a view...
AND.... how to include a block in a User Page??

Please help.
Riccardo.

Comments

Try this views recipe

andrewmacpherson's picture

Hi Riccardo,

You can make a GMap appear on a user page using Views, Location and GMap modules. Here are some instructions to get started. The attatched screenshot shows how it will look. I hope this is what you need!

Enabled modules

  • Drupal 6.10
  • Location (6.x-3.0)
  • User Locations (6.x-3.0, part of Location)
  • Gmap (6.x-1.0)
  • Views and Views UI (6.x-2.5)

Location and GMap settings

  • Make sure you enable user locations at admin/user/settings :-)
  • You will need to obtain a Google Maps API key for your domain (from Google). Enter this on the GMap settings page.
  • GMap settings - enable autozoom:Use AutoZoom, to make sure the user marker appears at the centre of the map. Chose a Maximum initial zoom so as not to zoom in too close (optional; I chose 7).

Views Settings

See attached settings diagram; also views-export code which you can import.

  1. Create a view of type "User" (important).
  2. Style: Gmap (defaults settings are okay - data source is location.module. Pick a nice marker colour.)
  3. Add a Block display; give it an admin name under Block Settings (I chose "User Map").
  4. Add an argument to the view - User:Uid. This will ensure only one user is shown on the map. Validate the argument as a User, and hide the view if the argument is missing or does not validate. The map will only show for users who have set a location. You could use some Empty text to say "user has not provided a location", or something similar.
  5. Enable some fields - e.g. User:Name and Location:City. These will show up in the GMap speech-bubble. I don't know how to get the speech bubble to appear by default, but maybe a GMap macro will accomplish that.

Block Settings

I placed the User Map block in the footer region of the Garland theme. (You could put it in any region; Content Bottom would be a better choice if your theme provides it.)
Important: You need to configure the User Map block, and set the Page Specific Visibility: only on listed pages to user/*. This ensures it only appears on the user page.

To summarize: you have enabled user locations, and created a block view which takes a user ID as an argument (therefore only shows one user). The block is configured to appear only on user pages, and does not show if the user has no location.

That should get you on your way - tweak the settings to suit yourself. Be sure to let us know how you get on, and Good luck!

Thanks!! But no luck

suffering drupal's picture

Hi Andrew,

Thanks for your detailed reply :-) and sorry for the late reaction :(
I have posted so many issues and have so many more in my head that I have lost track!
I already had something like you're describing, but anyway I've followed your instructions by the letter to try anew. No luck though :(

My Drupal configuration is as you suggest (or higher) and I checked both with the Marinelli theme I use as Garland.

I don't understand... do you think some other module like content-profile may be overwriting something in the configuration?
In fact strangely enough through the Content Profile module I AM ABLE to reproduce a map at the bottom of the user page, but it requires some confusing twists, let's see if I can explain:

Under content-profile you can add node-like content to a user and define fields for it.
It has a mandatory title field which then turns into a kind of alias for this 'user content-profile-node'.

1) If you now go to the 'normal' user page, the stuff from Content Profile is embedded there. You see the 'normal' user information (fields) plus the additional Content Profile info/fields. No map though.

2) However, if you go to the alias of the Content Profile, you only see CP info/fields (not the user avatar, because that's 'normal' user info) AND the block with the author-map!!!
This block was previously defined to appear under the user contents/footer of course.

When you give this Content Profile a title that is the same as the username, then when you go to the user, you see 2) - in other words, it overwrites the alias of the user.
This could lead to the option of putting all the user fields in Content Profile and just leave image/avatar and map to the 'normal' user fields. But then each user should know that they'd have to use their username as title for the Content Profile, a bit tricky. AND you loose the image on the userpage itself.

Anyway, I'd prefer to see your method work... so I'll keep on investigating.
If you have any clues on why it doesn't work on my site I will be happy to know.

Cheers!
Riccardo.

Same problem - any solution?

pragnatek's picture

Hi Riccardo,

I have the same problem also using content profile module. Did you ever get a solution to this?

Thanks,
Andy

Worked for me!

arilikeairy's picture

Thanks so much! I just spent the past 4-5 hours looking for this!

Works great with my set up.

I'm using the core profile module and everything else up to date as of today (fresh install to test this).
Just to be thorough: everything else = gmap, location, and views.

Problem with Views Arguments in Block Regions

arilikeairy's picture

The first time, I skipped the part about the views argument on accident -- I just realized that the block works without that argument, but doesn't work with it. (Block View used as a block.)

I've heard of this before...

You can't use a Block View within a block region (I read that here). Or, I guess, there are issues with Views Arguments when you try to. This page may also be helpful on that subject.

Creating a page, or using the Block View NOT in a block region works.

Hope this is helpful!

Aaack! Problem with Views Arguments in Block Regions

tonebari's picture

OK, so I did it as you mentioned, I set up a page view and went created a user-profile.tpl.php file for my user and then added a link there and a snippet of script to scrape the user uid from the url or alternately from $user. I stuck this variable in my link which I had set up in the view as mysite.com/user/%/map and also made a gmap-view-gmap.tpl.php theme file to display the map.
So, I opened up my page and it worked. Great! Except that the map used a goofy little marker with a little Drupal drop in the marker. So, I went into gMap settings and changed to another marker for the "page" display. Next the display goes away.... I revisited views and dumped my cache and all that and the views says "this display has no path" although the path is there plain as day. Ideas?

Block view could still be used as a block

rabielmo's picture

Thanks for posting this page, it came in quite handy!

Concerning the Block View, I used "Provide default argument" instead of "Hide view / Page not found (404)" as an action if the argument is not present and a default argument type of User ID from URL and that seems to display the map of the user's location as a block.

Hope this helps,

Ok i did this and there is a map for sure...

tbillion's picture

but it shows all the fricken nodes that the user has posted.. not the profile location. STARTING TO P me off. how do i narrow views to only show the profile location?

Location and Mapping

Group organizers

Group categories

Wiki type

Group notifications

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