GMap and Location Modules installed and enabled on Drupal 7:

GMap 7.x-1.x-dev
GMap Location 7.x-1.x-dev
GMap Macro Builder 7.x-1.x-dev
Location 7.x-3.x-dev

This error may be related to http://drupal.org/node/744426 and the gmap_plugin_style_gmap.inc file but I haven't been able to figure out the issue.

I opted not to use Node Location or Location CCK and instead have created my own fields to store street, city, state, zip, latitude, longitude and want to choose those fields to create the map view.

I created a node view using

View Defaults:

Filter by Node:Type
Fields:
Node: Title
Fields: Street
Fields: City
Fields: State
Fields: Zip
Fields: Latitude
Fields: Longitude
Node: Nid Nid

Page Display for View:

Style: GMap

Style Settings:
Grouping filed = None
Data Source = "Choose latitude and longitude fields"
Latitude Field = Fields: Latitude
Longitude Field = Fields: Longitude
Marker Handling = Use single marker type
Marker/fallback marker to use = Drupal

The result is a map page with no markers.

If I switch the Style

Style: Extended GMap

Style Settings:
Latitude Field = Marker latitude (Fields and Purposes)
Longitude Field = Marker Longitude (Fields and Purposes)
Grouping Field = None
Marker Click Action = Show formatted row in bubble
Marker Type = Small Red
Marker Handling = Use single marker type
Marker/fallback marker to use = Drupal

The result is the map displays with the marker and a opens the "bubble" when it's clicked. However I get the following notice:

Notice: Undefined index: in template_preprocess_gmap_views_view_gmapextended() (line 53 of Z:\xampp\htdocs\D7\sites\all\modules\gmap\gmap.views.inc).

Issue fork gmap-1077850

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

silverflame757’s picture

I was able to fix the error I got when using Extended GMap Style.

Error was:

Notice: Undefined index: in template_preprocess_gmap_views_view_gmapextended() (line 53 of Z:\xampp\htdocs\D7\sites\all\modules\gmap\gmap.views.inc).

The fix:

On lines starting at line 50 on gmap.views.inc I replaced

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

With

  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];
    }
  }

I still need help with a fix when using GMap Style.

iancawthorne’s picture

I think I could have the same or a very similar issue as described here. I too have chosen to avoid using the location module (as I only need latitude & longitude) and created decimal fields to store my longitude and latitude, then choosing "choose longitude and latitude fields" and specifying accordingly in the view config.

I don't get any errors, but my view is showing my markers at what I can only think is position 0, 0 just off Nigeria when they should be in the UK.

I have the same configuration, but using a cck decimal field in a Drupal 6 version of the site and this works fine.

I tried the code at #1, but this did not make any difference for me.

silverflame757’s picture

FileSize
15.47 KB

The patch at #1 is for using Style: Extended GMap

Here is an export of my D7 view using Style: GMap and fields of type: float, instead of the location module. The latitude/longitude values appear like this: 41.636800 / -70.539100

The markers appear in the Gulf of Guinea instead of it's position in the US.

Attached is an export of my view.

cees.vanegmond’s picture

Same issue as #2 here.

Worked fine in 6 but ported twe whole website today to 7 and having troubles.

I've setup 2 CKK decimal fields to my node, lat and lon.
Having setup my view properly the js script for loading the markers shows "markers":[{"latitude":15,"longitude":15, for nid 15 , "markers":[{"latitude":16,"longitude":16, for nid 16 and so on...

OSAMA’s picture

MAP is show but MArker are not ????

breos’s picture

Hello Silver, its hapenning the same to me. Using gmap, I can see the location of the mark in Guinea.

And, Using extended gmap, I'm getting the follow error:

'Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column \'latitude\' in \'field list\

And yes, I assign the correct (or I think correct) fileds to latitude and longitude (both float fields)

Any solution or you don't have done work it yet?

acke’s picture

The code in #1 fixed my notice:

Notice: Undefined index: i template_preprocess_gmap_views_view_gmapextended() (rad 53 av /home/test/public_html/sites/all/modules/gmap/gmap.views.inc).

mattbk’s picture

Superscribe.

mattbk’s picture

I was able to show markers by using the Extended GMap style rather than the regular GMap style in Views. With the regular style, it was showing markers for nodes that didn't even have data in the latitude and longitude fields even after clearing the caches. Weird.

mattbk’s picture

Status: Active » Needs review

I was also getting "Notice: Undefined index:" with some views using Extended GMap and the change in #1 fixed my issue.

Changing the status of this to "needs review" because of the possible fix by silverflame757 in #1.

dmiric’s picture

I dont know how much time I spent trying to get gmap to work like it should but with no luck. If I use my own lat/lon fields it simply dosent work marker is somewhere in the emptiness. I tried with decimal field also with simple text field. Not sure what else I could do.

this is what i found in js code ","longitude":"0","latitude":"40"}}});" and it makes no sense at all.

I'll just bump this since it a very old issue.

podarok’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Needs work

can You provide a patch against latest dev?

garrettrayj’s picture

FileSize
507 bytes

The solution from comment 1 worked for me. Here is a patch for 7.x-2.x.

podarok’s picture

Status: Needs work » Fixed

thanks

commited pushed to 7.x-2.x and backported to 7.x-1.x

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

CodigoVision’s picture

I was having a similar problem, where using separate longitude / latitude fields did not work, but I added the location field to the view and used it for the latitude and longitude with the default (address) widget and it's working!

taote’s picture

Status: Closed (fixed) » Active

Same thing happening here. I have a view with a map, where the latitude and longitude are part of a field of type location, and I'm not able to show the map with the marker.

I've tried with the GMap display, and Extended GMap setting the latitude and longitude, but the map is showed but no the marker.

Please help, I don't know what else to check.

CodigoVision’s picture

@taote Did you try what I mentioned in #16? Maybe I didn't explain it well. I have a location field called "Map" that uses a map on the node edit page to set the location. Then in the view I added my Map field, excluded it, and set the Formatter to "Default (address)". I'm using the regular Gmap format for the view, and in the settings I have the Data Source set to Choose latitude and longitude fields, with the Latitude set to Field: Map and the Longitude set to Field: Map.

taote’s picture

@Codigo Vision. Thanks for your reply. I did what you mentioned, and the marker is still not showing, but I've checked the option "Highlight marker on rollover" and when I hover the mouse over the location on the map where the marker should be, I can see a red circle, so the map it's locating the marker but not showing it. I've tried everything, I don'tknow what else to do.

Besides on the edit form, the marker is shown on the map, so I don't understand why not on the view.

CodigoVision’s picture

@taote I have not experienced that issue before. You might want to look into some of the other marker issues or open a separate issue. The only thing that comes to mind is that it could be a Javascript error blocking the marker from loading. You might want to use the console to check for errors. Ctrl+Shift+i in Chrome or F12 Firefox.

taote’s picture

I have compared the source code of the page where the map is rendered and the marker is not shown, and the one on the edit form where the marker is visible. And here are the differences:

Code for the marker in the map built by the view

<div style="width: 20px; height: 34px; overflow: hidden; position: absolute; opacity: 0.01; cursor: pointer; left: 444px; top: -32px; z-index: -3;" class="gmnoprint" title="">
      <img style="position: absolute; left: 0px; top: 0px; -moz-user-select: none; border: 0px none; padding: 0px; margin: 0px; width: auto; height: auto;" src="http://maps.gstatic.com/mapfiles/transparent.png" draggable="false">
</div>

Code for the marker in the map in the edit form

<div style="width: 22px; height: 40px; overflow: hidden; position: absolute; opacity: 0.01; left: -11px; top: -40px; z-index: 0;" class="gmnoprint">
      <img style="position: absolute; left: 0px; top: 0px; width: 22px; height: 40px; -moz-user-select: none; border: 0px none; padding: 0px; margin: 0px;" src="http://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-poi.png&amp;scale=1" draggable="false" usemap="#gmimap0"><map name="gmimap0" id="gmimap0"><area log="miw" coords="8,0,5,1,4,2,3,3,2,4,2,5,1,6,1,7,0,8,0,14,1,15,1,16,2,17,2,18,3,19,3,20,4,21,5,22,5,23,6,24,7,25,7,27,8,28,8,29,9,30,9,33,10,34,10,40,11,40,11,34,12,33,12,30,13,29,13,28,14,27,14,25,15,24,16,23,16,22,17,21,18,20,18,19,19,18,19,17,20,16,20,15,21,14,21,8,20,7,20,6,19,5,19,4,18,3,17,2,16,1,14,1,13,0,8,0" shape="poly" title="" style="cursor: pointer;"></map>
</div>

So the marker is there and positioned, but I don't know why the marker in the map is a transparent png, when I have selected the red arrow. Any ideas?

taote’s picture

Ok, it works when I select in the GMap options Default for Marker / fallback marker to use. The problem is when I want to use a different marker.

ericwongcm’s picture

Version: 7.x-2.x-dev » 7.x-2.8

I believe this bug is still there. Steps to reproduce.
1) Create a node content type which contains location CCK field
2) Create a Gmap view for this content type
3) Add relationship -> the location CCK field you are created for this content type in (1)
4) Add fields, location: coordinates or location: latitude and location: longitude
Under relationship -> select the location CCK field relationship selected in (3).
Under Display style, select Decimal degrees because this is the format gmap says it needs in (5).
This step is important or else you can't get the coordinate from the location CCK field.
5) Gmap settings -> Choose latitude and longitude fields
Latitude field -> choose the "location: latitude" field you created in step (4)
Longitude field -> choose the "location: longitude" field you created in step (4)

Note: using "location: coordinates" for both Latitude field and Longitude field produces the same result.

In the help text, it says "Format must be degrees decimal."
This is why we need to use Decimal degrees in step (4).
Yes, there is an obvious order typo here.
6) Configure your path and take a look. There is no map. The Gmap page is blank.

Optional: to check if you are getting the coordinate output, change to unformatted list instead.

I know I shouldn't be doing this complicated setup to get the points on the map. I should be referencing location fields directly using views which works perfectly fine in my setup.

The reason I am doing this is because I have multiple location CCK fields in the same node and I need to use views_conditional (https://drupal.org/project/views_conditional) to control which location fields coordinate to use to put the point on the map. In other words, I am using views_conditional to remove the duplicate nodes on the MAP which carries a different address.

This is the issue tracker for the duplicate location results in views.
https://drupal.org/node/460674

Does anyone have a solution for this problem?

Note: I am using GMAP 7.x-2.8. I am not using 7.x-2.9 because my shared server does not use php 5.3 yet.

ericwongcm’s picture

A simpler way to test this is to simply create two fields, one holds latitude and the other longitude.
If you select format: Gmap and Choose latitude and longitude fields
Pick these latitude and longitude fields, the Gmap views output will be blank but you can see both fields show up correctly using unformatted list.

However, if you use Extended Gmap, Choose latitude and longitude fields and select the same fields for marker latitude and marker longitude. The extended Gmap output works as expected.

Looks like I will have to use Extended Gmap as a work around until there is a fix for Gmap.

recrit’s picture

Version: 7.x-2.8 » 7.x-2.x-dev
Status: Active » Needs review
FileSize
3.21 KB

Cause: The fields as a datasource in the views plugin was assuming a field array instead of a views result field.
Fix: The attached patch correctly determines the views field alias for the selected fields and processes the rows for the map.
Note: the patch is rolled on the latest 7.x-2.x-dev as of 43a9db6.

Status: Needs review » Needs work
ericwongcm’s picture

I have manually applied your patch to Gmap 7.x-2.9. This bug seems to be fixed now. Great work.

ericwongcm’s picture

However, if I do this....
https://www.drupal.org/node/2270043

I will get this error when I open this view page.

Notice: Undefined property: stdClass::$views_conditional_9 in gmap_plugin_style_gmap->render() (line 217 of /public_html/sites/all/modules/gmap/gmap_plugin_style_gmap.inc).
Notice: Undefined property: stdClass::$views_conditional_9 in gmap_plugin_style_gmap->render() (line 218 of /public_html/sites/all/modules/gmap/gmap_plugin_style_gmap.inc).

Any idea how to fix this?

hockey2112’s picture

#18 worked for me. Thanks!

CProfessionals’s picture

#18 worked for me.

It seems that (as stated above) the Lat and Long selectors are looking for an array and it is smart enough to extract the Lat long from the array. I put the location default address field in for both selectors.

Putting in a specific Lat and a Long field did not work (as stated above).

Just wanted to post that this is still an issue.

the_g_bomb made their first commit to this issue’s fork.

podarok’s picture

Version: 7.x-2.x-dev » 3.0.x-dev
Status: Needs work » Fixed

Merged, thanks
Tagged in 3.0.0 release

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.