By geerlingguy on
I have a simple need for a site I'm working on, to make it so that a user can enter a street address, then when the street address is displayed in a view I set up, the street address becomes a link to Google Maps with a map of that address...
I was playing around for quite a while with the 'Location' module, but couldn't figure out, for the life of me, how to get it to make a link to a map address. It's also confusing how the Location module works in general (and I couldn't find much documentation).
Any help would be appreciated; here's the page I'm working on:
http://c246-2.teamholistic.net/id-card-dates
Comments
Drupal 5 CCK Location: see map link
I can tell you what I did with CCK Location in Drupal 5. Maybe it hasn't changed a lot in Drupal 6.
With this setup, my User can enter the address when they add the node and it automatically generates a "See Map" link when the node is viewed.
Get a free map key from Google
--- http://code.google.com/apis/maps/signup.html
admin/build/modules
--- Enable Location
--- Location CCK is listed with the CCK modules, but I didn't enable it.
Run update.php
admin/settings/location
--- maplinking tab: select your country and the Google map service
--- geocoding tab: select your country and the Google map service
--- --- Next to the country is a Configuration link.
--- --- This is where you enter your Google map key.
admin/content/types
--- Edit each content_type that you want to have a Location.
--- --- On the first page where you set the Title and Body, scroll down to Location.
--- --- Set your preferences for how many locations and which location fields to allow.
--- --- Check your other content_types
--- --- There may be some defaults set that you want to remove.
--- --- One of my updates had Default locations set to '3' on every content_type.
Thanks! I will try going
Thanks! I will try going through these steps, and I'll see if I can't get the map links to show. I'll post back here later, after I get time to work on it a little more.
__________________
Personal site: www.jeffgeerling.com
I followed these directions,
I followed these directions, but can't find out how to get a map link to show up. I can't get the map link to show in either the node or the views table...
__________________
Personal site: www.jeffgeerling.com
See http://drupal.org/node/346694
Found this in my notes.
Location
Go to map link would not display, even when set to enable in content_type's setting
http://drupal.org/node/346694
Thanks!
As outlined in your link, I changed the 'if' statement in location.module to:
if (!$variables['hide']['map_link']) {and it now displays a little line that says "See map: Google Maps" - so that's working fine. I'm going to start working on making that link show up in the display of the address, instead of on its own line—is this even possible with the Location module?
__________________
Personal site: www.jeffgeerling.com
Location module: You can limit what's visible of the address
In the admin content_type settings, where you set how many locations and what info to collect, you can also set what info to display. You could display just the name with the link under it.
You don't always get what you want; but you can always get what you need with Drupal.
You don't always get what
You don't always get what you want; but you can always get what you need with Drupal.
Classic line! Of course, I have so far almost always gotten what I wanted. Just not quite this time. It's good enough for now, but eventually, it'd be great to get a Location map link as a clickable field for use in views.
__________________
Personal site: www.jeffgeerling.com
Views: adding a link to the map
Another approach.
Thank you! Creative workaround :)
Thank you for your idea! That will work perfectly for me; it's a little work, and not the most elegant thing in the world, but it fixes my problem. Hopefully a map link will be accessible in the Location module's settings someday...
__________________
Personal site: www.jeffgeerling.com
so, as I understand, this
so, as I understand, this link will lead me into node locations page (http://mysite.ru/map/node)?
Its helpful to note that you
Its helpful to note that you can create custom URLs in google maps to search for a specific place, so you can override a field in your view to output as a link and use the views Replacement Patterns (tokens) to create that URL. This stackoverflow page helped me figure this out
If anyone is still looking for a way to do this in views this is the way I did it:
In your view add the Street, City, and Postal Code fields before the field that you want to appear as a link to google maps, and exclude the Street, City, and Postal Code fields from display.
In the field options for the filed you want to appear as a link to google maps click on the "Output this field as a link" check box. Below a new field will appear called "Link Path" Here start off with this http://www.maps.google.com?q= now enter your tokens putting a + in between each token. Mine looks like this http://www.maps.google.com?q=[street_1]+[city_1]+[postal_code_1] Now update your changes to the field and save your view.