I thought I give integration with gmap through views a go.
And it almost works, keep up the work with this great module

Actions taken
- create a page view
- add a field -> Content:Geolocation -> Formatter = Latitude text-based formatter
- add a field -> Content:Geolocation -> Formatter = Longitude text-based formatter
- Format choose gmap
- Gmap settings -> Data source = choose latitude and longitude fields -> latitude field = (first) Content:Geolocation -> longitude field = (second) Content:Geolocation

Result
- I get a map with a Drupal marker on it, yeah...
- But the marker is on position longitude / longitude.

No matter what fields I select in the gmap settings it will only place markers on longitude / longitude.

Comments

botris’s picture

Turns out the marker is not on longitude/longitude but it takes the entity_id and parses that.

So I excluded the Content:Geolocation from display and made two Global:php fields in views, one with output code:

<?php
print $data->field_data_field_geolocation_node_values[0]['lat'];
?>

and one with:

<?php
print $data->field_data_field_geolocation_node_values[0]['lng'];
?>

In a text based view, this outputs both values nicely, so it might work with OpenLayers, but with Gmap I get two errors:

Notice: Undefined property: stdClass::$views_php_2 in gmap_plugin_style_gmap->render() (line 154 of /Applications/MAMP/htdocs/site/sites/all/modules/gmap/gmap_plugin_style_gmap.inc).
Notice: Undefined property: stdClass::$views_php_3 in gmap_plugin_style_gmap->render() (line 155 of /Applications/MAMP/htdocs/site/sites/all/modules/gmap/gmap_plugin_style_gmap.inc).

botris’s picture

Ok Global:php is the way to go for now to get Lat & Long info into views.

Displaying it on a map works with the "Extended GMap" format in views.
In the Extended GMap settings select Marker latitude with the corresponding Global:php field and Marker longitude with the other Global:php field.

Tip, when configuring the Global:php fields under "More" give the field a new administrative title, like 'Latitude' this makes selecting it easier.

andrea.cavattoni’s picture

I'm trying to do that with Global:php and extended Gmap, but i got an error:

Notice: Undefined property: stdClass::$field_data_field_geolocation_node_values in __lambda_func() (line 1 of /var/www/evxsf/modules/views_php/plugins/views/views_php_handler_field.inc(131) : runtime-created function).

How can i get this working?

andrea.cavattoni’s picture

i still get an error and the marker is at the top part:-/
Notice: Undefined index: in template_preprocess_gmap_views_view_gmapextended() (line 53 of /var/www/evdfs/modules/gmap/gmap.views.inc).

andrea.cavattoni’s picture

fixed changing the gmap.views.inc al line 53 this:

 foreach ($renders as $i => $row) {
    $markers[$i] = $options['fallback_values'];
    foreach ($options['field_purposes'] as $field => $purpose) {
      $markers[$i][$purpose] .= $row[$field];
    }
  }

with this

  foreach ($renders as $i => $row) {
    $markers[$i] = $options['fallback_values'];
    foreach ($options['field_purposes'] as $field => $purpose) {
      if (!isset($markers[$i][$purpose])) {
        $markers[$i][$purpose] = '';
      }
      $markers[$i][$purpose] .= $row[$field];
    }
  }

but i got:

Notice: Undefined property: stdClass::$field_data_field_location_node_values in __lambda_func() (line 2 of /var/www/eventsapp7/modules/views_php/plugins/views/views_php_handler_field.inc(202) : runtime-created function).
andrea.cavattoni’s picture

Fixed using another way.
Still using extended gmap, but i had tu use the filed content that i've created before in cck.

So i used simply the field from cck (field_geolocation) for 2 times, one formatted as latitude and one formatted as long.
Now you can use the 2 fields in Extend gmap, one for lat and the other one for lng...

Is not necessary use Global:php and it doesnt work:(

iancawthorne’s picture

Subscribing.

iancawthorne’s picture

I think the error message :

Notice: Undefined index: in template_preprocess_gmap_views_view_gmapextended() (line 53 of /var/www/evdfs/modules/gmap/gmap.views.inc).

which I also get using Gmap extend is a Gmap module issue, as I have tried using the Geofield (http://drupal.org/project/geofield) module fields and get exactly the same result.

iancawthorne’s picture

vacilando’s picture

cavax is right in #6 -- there is no need to use PHP with Extended GMap formatter.

Still, we should also be able to get this going with the GMap formatter. Any luck, anybody?

Oceanman’s picture

This old thread is marked postponed http://drupal.org/node/1213668 but seems to be the same topic as here.

Has there been any progress with this? Has anyone found a solution to putting all your lat-long data (markers) on the same map?

rickharington’s picture

Im not getting any errors but I'm not getting any markers either. Just an empty map. It would be great if someone can export their view so that we can have a look if they got it working. I used the two fields as discussed above.

xandeadx’s picture

replace in gmap_plugin_style_gmap.inc:

    // Determine fieldname for latitude and longitude fields.
    if ($this->options['datasource'] == 'fields') {
      $lat_fied_obj = $this->view->display_handler->get_handler('field', $this->options['latfield']);
      $lon_field_obj = $this->view->display_handler->get_handler('field', $this->options['lonfield']);
      $lat_field = $lat_fied_obj->field_alias;
      $lon_field = $lon_field_obj->field_alias;
    }

to

    // Determine fieldname for latitude and longitude fields.
    if ($this->options['datasource'] == 'fields') {
      $lat_field = 'field_' . $this->options['latfield'];
      $lon_field = 'field_' . $this->options['lonfield'];
    }

and

        $lat = (float)$row->{$lat_field};
        $lon = (float)$row->{$lon_field};

replace to

        $lat = (float)$row->{$lat_field}[0]['raw']['lat'];
        $lon = (float)$row->{$lon_field}[0]['raw']['lng'];
christianadamski’s picture

Component: Geolocation field » Geolocation Field / Backend
Issue summary: View changes
Status: Active » Closed (won't fix)

Closing all 7.x issues. It's time.