Gmap view + Location + CCK

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

I have a database of property data with lat/long and I would like to display this information in a google map. I used CCK to create the fields and created a view using Gmap view. The key is to show multiple properties on the same google map. I tried to follow Zacker's google mashup machine but didn't succeed. I would appreciate any tips. I am also keen on hiring a consultant to help me out on this project.

Arthur

Comments

GMap Views

mackh's picture

Hi

You need to use the views module to output the map as a view type.

Look for the gmap_views.module file in the gmap module folder - you should be able to create gmap type views with that.

You can expose filters and pass arguments on the view to limit the result set.

Like this -> http://relocalize.net/maps

Hope this helps
-M

Also...

NikLP's picture

Further to that, the "mashup machine" is completely out of date - this functionality is replaced by what mack describes above.

Web Development in Nottingham, UK by Kineta Systems

GMAP + Location + CCK

aoduma's picture

I have created a View with GMAP Views type. I get a google map but it doesn't seem right. Could it be the template file? Here's the template.php code. Also, I have indicated the fields in the View.
TEMPLATE>PHP file
**
* views template to output a view.
* This code was generated by the views theming wizard
* Date: Sat, 05/24/2008 - 13:24
* View: Property_maps
*
* This function goes in your template.php file
*/
function phptemplate_views_view_list_Property_maps($view, $nodes, $type) {
$fields = _views_get_fields();

$taken = array();

// Set up the fields in nicely named chunks.
foreach ($view->field as $id => $field) {
$field_name = $field['field'];
if (isset($taken[$field_name])) {
$field_name = $field['queryname'];
}
$taken[$field_name] = true;
$field_names[$id] = $field_name;
}

// Set up some variables that won't change.
$base_vars = array(
'view' => $view,
'view_type' => $type,
);

foreach ($nodes as $i => $node) {
$vars = $base_vars;
$vars['node'] = $node;
$vars['count'] = $i;
$vars['stripe'] = $i % 2 ? 'even' : 'odd';
foreach ($view->field as $id => $field) {
$name = $field_names[$id];
$vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
if (isset($field['label'])) {
$vars[$name . '_label'] = $field['label'];
}
}
$items[] = _phptemplate_callback('views-list-Property_maps', $vars);
}
if ($items) {
return theme('item_list', $items);
}
}
THEME FIELDS

These functions will override the given fields for just this view:

Location: Name
phptemplate_views_handle_field_Property_maps_location_name

Location: Street
phptemplate_views_handle_field_Property_maps_location_street

Location: City
phptemplate_views_handle_field_Property_maps_location_city

Location: Province
phptemplate_views_handle_field_Property_maps_location_province

Location: Postal Code
phptemplate_views_handle_field_Property_maps_location_postal_code

Location: Country
phptemplate_views_handle_field_Property_maps_location_country

Location: Latitude
phptemplate_views_handle_field_Property_maps_location_latitude

Location: Longitude
phptemplate_views_handle_field_Property_maps_location_longitude

These functions will override the given fields for every view:

Location: Name
phptemplate_views_handle_field_location_name

Location: Street
phptemplate_views_handle_field_location_street

Location: City
phptemplate_views_handle_field_location_city

Location: Province
phptemplate_views_handle_field_location_province

Location: Postal Code
phptemplate_views_handle_field_location_postal_code

Location: Country
phptemplate_views_handle_field_location_country

Location: Latitude
phptemplate_views_handle_field_location_latitude

Location: Longitude
phptemplate_views_handle_field_location_longitude

Arthur

iframe + Gmaps

raintonr's picture

Hi,

We solved this problem using an iframe and gmaps, like this:

<iframe width="525" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com.au/?q=http:%2F%2Fnobmob.com%2Fkml%2Fterm%2F15&amp;ie=UTF8&amp;ll=-33.695079,151.223822&amp;spn=0.165442,0.12604&amp;om=1&amp;output=embed&amp;s=AARTsJqg2Pa7tnr_mQ9odyKdW-dtdOZF2Q"></iframe>

Not particularly elegant, but it works quiet well, you can see the result here:

http://nobmob.com/rides

Of course you can use this method to display any number of nodes or taxonomies, etc.

Oh, I should mention I have customised the KML module to provide different icons for different node types, this is where the stars come from. Images show as cameras as you can see here:

http://maps.google.com.au/?q=http:%2F%2Fnobmob.com%2Fkml%2Fterm%2F362

What exactly do you pass

cpill's picture

What exactly do you pass over to the IFrame? Is this a GMap Macro?

It works!

Andy Inman's picture

(Edited) Now it works!

I've got the View defined like this:

  • Page
    Provide page view (yes)
    View Type: Gmap View
    Nodes per page: 99

  • Fields
    Location: Latitude
    Location: Longitude

  • Filters
    Node: Type Is One Of (required node types)

  • Exposed Filter
    Node: Type



Currently part of the team at https://lastcallmedia.com in a senior Drupal specialist role.

Works for me Too!

cbrompton-gdo's picture

I have the same settings as netgenius but with the addition of a few more fields.
Everything seems to work; however, I would like to be able to expose more filters but they look so #(*&$# ugly!
any suggestions on how to style them. here is my example. ( I pulled all the exposed filters)

http://pacificvirtualtours.ca/google/map

Tell me what you guys think...

I would also subscribe to

kirilius's picture

I would also subscribe to this.

The original question was about a CCK type fields displayed in the view. In Drupal 6 (not sure about previous versions) these fields are simply not available for selection in the view. Do you know a way around this?

I'm trying to do this too,

keyone's picture

I'm trying to do this too, and want the map in the view to just show the current node from a given node type (restuarants) and nodes within x miles of another node type (nearbyattractions). Any tips?

gmap.views.inc

cpill's picture

I can't see the gmap_views.module file? I can see a: gmap.views.inc but it has the key function commented out? Whats that all about?

View Type: Gmap View

spelcheck's picture

I have Views, Location and GMap modules installed but the 'Gmap View'
option isn't available in Views. Anyone else having this problem?

http://groups.drupal.org/node/19614
- Create view using View Type: Node
- use GMap as the Style

Not sure why the Gmap option isn't showing up as a "View Type:" as everyone else is stating, but this works for me.

This is quite an old thread

tom_o_t's picture

This is quite an old thread - things changed in Views 2 and GMap 6.x
Check out some basic documentation at http://groups.drupal.org/node/19614 for more up-to-date instructions.

Note

greg.harvey's picture

It seems if you set view "Row style" to Fields, when you go to add fields the "Content" group (provided by the CCK module) is missing. This is quite an issue at the moment. Hopefully it will be resolved soon. =)

Edit: It's actually the Location view type that causes this, nothing to do with GMap, but it is affected.

More info?

sagannotcarl's picture

Hey greg.harvey,
Do you have any links to issues or patches that deal with this issue. I agree it's pretty frustrating and would love to help to get it resolved.

Thanks!


[ Quilted. Stitching Together Technology and Social Change ]


[ Quilted, Stitching Together Technology and Social Change ]

Not handy

greg.harvey's picture

But it works fine with D6/Views 2. The trick is you need a NODE type view, not a LOCATION type view. After that, it works intuitively, as you would expect assuming you are familiar with Views 2. =)

Ahh, got it. Thanks for the

sagannotcarl's picture

Ahh, got it. Thanks for the tip!

If anyone else is looking for specific instructions I also came across these instructions which look helpful as well.

http://drupal.org/node/386848


[ Quilted, Stitching Together Technology and Social Change ]

Also

greg.harvey's picture

Take a look at this for Views + proximity searching using Google Maps API + Location:
http://drupal.org/node/321114

Current patch works well for US and UK, as far as I can tell.

All very nice, but it's all "views"......

suffering drupal's picture

IS it or IS IT NOT possible to just have a map for a user????
Just something simple like expose a list of users, click user to go to his personal page and find his address + corresponding MAP right away. ¿Possible without views, coding or patching?

Excuse, but it is really upsetting, frustrating and demotivating not to find any reply to such an elementary thing....
This keeps newbies away or leaves die-hards like me suffering in the newbie-stage for more than a year. Gives the feeling that Drupal is only for an advanced incrowd.
I am sure I am not the only one having heard Drupal is great and then just bump into walls over and over again. More people with the same problem at: http://groups.drupal.org/node/17148

Two ways

greg.harvey's picture

If you're in Drupal 6.x (if you're not, you should seriously consider upgrading) then you may create user views, so you can create a view with a custom macro and showing the user against an argument to achieve this. In other words, Location + GMap + Views 2 already meets your requirements.

Secondly (but less customisable) there is an option somewhere in the Location module's settings to show a link to the Google Map for a given piece of content (including users) under the Location data when viewing. This would also do what you want, but the Views approach is more flexible, albeit not available to Drupal 5.x users.

If you're in Drupal 5.x you'll have to get creative with Views 1 + Usernode, I guess. That's how I used to do it, with Location data on the usernode for the user.

I second the above opinion..

lyosef's picture

...and it troubles me that you're still struggling after over a year. Makes me wonder how I will fare.

I'll give it a try

suffering drupal's picture

Hi Greg,
Thanks for your answer!
You really are talking about a map that shows up under the user at domain.com/users/username, not just a block? (if so, how should I get that block in the user?)

I'll give it a try as soon as I can. And I will inform! ;)
I am on 6, fortunately :)

Welcome

greg.harvey's picture

No problem - remember, any view can be a page as well as a block, so there's your block! =)

I can't remember what it looks like off the top of my head, but views argument handler for users should already support using the currently logged in user, which will make that block always available.

HTH =)

replacment for location map block

mrgoltra's picture

Good Day,

I have been trying to find a replacement for the location map block using location cck + views + gmap(to show location associated with node). I was able to create a map view with content type. It will show all markers. Now, I need to filter just to show the address associated with that node. I tried node:nid with operator set to is equal to and for the Value field I have tried: %, %nid, *, [nid] and still doesn't work.

Thank you,

Mark

external Data displayed in drupal

design10's picture

This might be a start to you doing what you need.

This is a good module
http://drupal.org/project/tw

Here is my example of a static table of all of the NGS geodetic monuments for lexington county.
This is a large dataset so be patient

http://garsedlandsurvey.com/test/ngs/map

Your table must have the dru_ (or your specific) prefix if you want to create your own table without the TW tools as I did for this example.
TW allows for import of csv tables.

The default view for this datatype is a list so create then clone and change the Style under Basic Settings For the view to GMAP. Futs with it until you are happy You can also rewrite the output to link these to individual nodes and include a map of a single property with directions etc,

GMap + View + CCK

mmDrupal's picture

Hi,

I am totally new to Drupla & php. Recently, I discovered Drupal & am switching from ASP.Net. Anyway, I am trying to build an earthquake related site & want to show maps of earthquakes. So, regarding the following recommendation for using ifarme to show the map, can you please be kind to provide more info on where to add this? Also, how can I pass lat/lon variables to the frame rather than numbers.

Thanks in advance for your help.

iframe width="525" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com.au/?q=http:%2F%2Fnobmob.com%2Fkml%2Fterm%2F15&ie=UTF8&ll=-33.695079,151.223822&spn=0.165442,0.12604&om=1&output=embed&s=AARTsJqg2Pa7tnr_mQ9odyKdW-dtdOZF2Q"

Several ways to approach this problem.

design10's picture

If it were me I would use modules rather than custom code.

First of all I would have a look at the location module and the Gmap Module.
http://drupal.org/project/location
http://drupal.org/project/gmap

If you are new to DRUPAL get ready to configure, configure, and configure some more.
(once configured though its off to the races)

  1. GMAP and LOCATION or CCK location field.
  • Create a new Content Type "earthquakes".
  • Configure it for one or more locations(one to start)
  • Add location block to content area(this will display your earthquake on a map per node)
  • Create a new view type "node"
  • In the view Style select "GMAP" and use location module in the Settings.
  • Add some fields from location and node.
  • Experiment
  • Use taxonomy to classify your earthquake by region.

Take a look at the table wizard module
http://drupal.org/project/tw

  1. Table Wizard and GMAP (note: you must use Views version .dev or 2.6)
    If you have a table of earthquake data this is the fastest method (also you can look at node import)
  • create and populate your Mysql table in your drupal database complete with prefix.
  • Import the table using Table Wizard
    A new view "type" will be created for each table imported.
  • Create a new view type "TW_your_table_name"
  • In the view Style select "GMAP" and specify your lat and long fields in the settings.
  • Add some fields from location and node.
  • Experiment
  • Use taxonomy to classify your earthquake by region.

If you need more help just let me know.
Good luck!!

P.S. its probably not as good idea to post your api key in a forum.

THE ANSWER

Brian317's picture

Is here - in a convenient video tutorial

http://www.drupalove.com/drupal-video/gmap-location-module-basics-drupal-6

The only thing that took me a few seconds to get straight was not being able to read his screen very well, so here's the code you're looking for:

  <?php
  $lat
= $location[latitude];
   
$long = $location[longitude];
  print
gmap_simple_map($lat, $long, '', $title, 10, '300px', '250px', false, ''); 
?>

gmap_simple_map The parameters in a list:

gmap_simple_map($latitude, $longitude, $markername = '', $info = '', $zoom = 'auto', $width = 'default', $height = 'default', $autoshow = FALSE, $map = array())

This thorough explanation worked PERFECT for me. Just set up the sequel tutorial of a view that shows all your nodes of a type on one map on a new page, which is pretty easy too. http://www.drupalove.com/drupal-video/gmap-location-module-and-views

Hope you're good now!

missing something

liquidcms's picture

i have a node view as style unformatted. In this i add a Location field which shows up with my fields and simply a link to the google map (on google.com). I also add a CCK field for the same location field as it gives me the formatter Address with Map (which does work fine as simple cck display formatter when looking directly at the node) - but in my View it simply shows the label and nothing else.

When i switch my view style to Gmap with the same fields; preview says i can't display; but when i save.. my view now displays nothing.. for any of my fields.

oops...

liquidcms's picture

you'd think gmap would be a little more helpful; but turned out my address didn't match the postal code i had entered.. in which case gmap just silently fails

Get current location display as a marker

quocnam15's picture

How to get current location display as a marker on map?i am using gmap,location module(d7)

Sad: won't fix (perhaps)

RaulMuroc's picture

IS looking no movement on this topic so far :(

Raül Rodríguez Cabestany
Software Engineer

Anno 2014 heaps of solutions out there..

RdeBoer's picture

Start with https://www.drupal.org/node/1704948

For obvious reasons my personal favorite starting point is http://drupal.org/project/ip_geoloc
Check out the project page for more references, videos etc.

Location and Mapping

Group organizers

Group categories

Wiki type

Group notifications

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