Hi

I have added a location CCK field to a content type.
In the display option I selected "show address and map" for the "full content"; however, this it is only showing the address with the LINK to Google Maps, but NO actual embedded map.
Please look at screenshots. Any help is appreciated.

Thanks.
Youssef

Comments

rooby’s picture

Title: Loation modules - Drupal 7 - Map not showing » Loation cck field formatters that use gmaps don't work properly
Category: support » bug

I know about this but have not had a chance to track down the problem yet.

It is a bug that affects all formatters that use gmaps in their display.

If you are getting "Javascript is required to view this map" instead of a map it is the same problem I have seen (Your screenshots don't seem to have attached correctly).

youssefr’s picture

StatusFileSize
new18.1 KB
new24.4 KB
youssefr’s picture

Hi
by the way, I am not getting "Javascript is required to view this map"
Thanks

tonycpsu’s picture

Subscribe

natkitten’s picture

StatusFileSize
new22.6 KB
new9.6 KB

Hello!
Looks like it's the same issue with my installation.
And this can hardly be the mentioned javascript gmap issue
On my site only "Array" shows up instead of coordinate chooser on node editing form.
But on Gmap settings and macro creation pages all maps are displayed properly.

rooby’s picture

@natkitten:

Have you checked the "Use a Google Map to set latitude and longitude " option on the location settings page (admin/config/content/location/main)?

This issue is for when you are viewing a node, not editing a node.

The "Array" you see is another issue, see #1056148: 'Array' appears at the bottom of locations on node edit page.

natkitten’s picture

Oh my... sorry for posting a stupid question to the wrong thread...
"Use a Google Map..." hasn't been checked...
Thanks so much! I just used the wrong administration page assuming everything necessary was in "gmap location" settings...
Node edit works fine now.
And the "javascript required" issue belongs completely to Gmap module, i guess.

Shubin’s picture

I am also having problems displaying the actual map image. I get the same appearance as youssefr with only the coords appearing and no google map.

movemaine’s picture

I'm also having this issue. I have tried everything above - made sure the block was active as well - no change.
I just get the label and no map.

movemaine’s picture

youssefr’s picture

Posted by movemaine on April 23, 2011 at 9:20pm new

Ended up using this:
https://github.com/mindtree/BingMapsDrupal

Hi
Do you have a link or sample working link for this.
Thank you.

Youssef

movemaine’s picture

Unfortunately, the bing map broke javascript on the page.

problue solutions’s picture

This issue exists in the latest 6.x version also.

paulgemini’s picture

subbing

rooby’s picture

I have the fix for this, coming asap.
Will have time to give some location love again very soon.

youssefr’s picture

Thanks rooby !

Allan Walker’s picture

subscribing!

Allan Walker’s picture

Title: Loation cck field formatters that use gmaps don't work properly » Location cck field formatters that use gmaps don't work properly
rooby’s picture

Status: Active » Needs review
StatusFileSize
new701 bytes

Try this.
Should work for all 3 formatters that use the map.

youssefr’s picture

Hi

I added the code below to the template.php file but still no results. Any ideas?
(MYTHEMENAME replaced with my active theme ninesixty)

Thanks.

function MYTHEMENAME_location_cck_field_map($variables) {
$map['longitude'] = $markers[0]['longitude'];
$map['markers'] = $markers;
$map['id'] = gmap_get_auto_mapid();
$content = theme('gmap', array('element' => array('#gmap_settings' => $map)));
// Render a map element.
$location_map = array(
'#type' => 'gmap',
'#gmap_settings' => $map,
);
$content = drupal_render($location_map);
}
return $content;
rooby’s picture

That is not the complete code of the theme_location_cck_field_map() function, it is just the portion of it that was patched, so it won't work by itself. It has to be the current code in that function combined with the changes in the patch file.

You don't have to add anything to your template.php file.
Just apply the patch in #19 to the location module and the problem should be fixed.
Then if people can report here whether or not the patch fixes the problem (does for my testing) it can be committed to the module.

There is loads of patch related informatino at http://drupal.org/patch and its related pages.
for this patch you should be able to just copy the patch file into the location module folder (the main folder, not the location_cck one) and run the following command (from within the location directory):
patch -p1 < location-cck_map_formatters-1089344-19.patch

youssefr’s picture

Hi
I have copied the patch and run the last line in #21.
...sites/all/modules/location$ patch -p1 < location-cck_map_formatters-1089344-19.patch

The output was the following:

patching file contrib/location_cck/location_cck.module
Hunk #1 FAILED at 475.
1 out of 1 hunk FAILED -- saving rejects to file contrib/location_cck/location_cck.module.rej

Thanks.

rooby’s picture

Looks like you are doing the right thing,
When I run it I get:

patching file contrib/location_cck/location_cck.module
Hunk #1 succeeded at 477 (offset 2 lines).

Are you using the latest location 7.x-3.x-dev?

rooby’s picture

When you are finished the function should look like:

<?php
/**
 * Generate a GMap map for one or more location field values.
 *
 * Mostly just cut and paste from gmap_location
 * block view.
 */
function theme_location_cck_field_map($variables) {
  $locations = $variables['locations'];
  $field = $variables['field'];
  $instance = $variables['instance'];

  $count = 0;
  $content = '';
  foreach ($locations as $location) {
    if (location_has_coordinates($location)) {
      $count++;
      $markername = isset($field['settings']['gmap_marker']) ? $field['settings']['gmap_marker'] : 'drupal';
      $markers[] = array(
        'latitude' => $location['latitude'],
        'longitude' => $location['longitude'],
        'markername' => $markername,
        'offset' => $count-1,
        'text' => theme('location_cck_field_popup', array('location' => $location, 'instance' => $instance)),
      );
    }
  }
  if (!empty($markers)) {
    $macro = !empty($field['settings']['gmap_macro']) ? $field['settings']['gmap_macro'] : '[gmap ]';
    $map = array_merge(gmap_defaults(), gmap_parse_macro($macro));
    $map['latitude'] = $markers[0]['latitude'];
    $map['longitude'] = $markers[0]['longitude'];
    $map['markers'] = $markers;
    $map['id'] = gmap_get_auto_mapid();
    // Render a map element.
    $location_map = array(
      '#type' => 'gmap',
      '#gmap_settings' => $map,
    );
    $content = drupal_render($location_map);
  }

  return $content;
}
?>

You could even try just replacing the function with the code here but if you are not using the latest 7.x-3.x it may cause problems to do that depending on what your version is.

youssefr’s picture

I am using Location 6.x-3.x-dev (2011-Feb-25)

rooby’s picture

Ah, that's why then. This issue is for drupal 7 so the patch is for drupal 7 too.
When I get home tonight I'll make one for drupal 6 and post it here.

The fix should be similar but the code in this one definitely won't work with drupal 6 even if you manually copy the code I posted above.

barmentalisk’s picture

rooby, thank you! your patch solved my problems and now the map is printed in my nodes!
i just had manually opened location_cck.module in editor and paste your changes.

rooby’s picture

For all those who say they have this problem in drupal 6 can you give some more details of what your problem is.
I cannot reproduce this on drupal 6 running location 6.x-3.x-dev.

If the problem is that the "Multiple field values on a single map" display formatter is not working you want this issue #841340: Location CCK and Multiple field values on a single map

youssefr’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
StatusFileSize
new86.72 KB

Hi,

I have been able to reproduce 'not seeing the map' using Location 6.x-3.x-dev (2011-Feb-25) with Drupal 6.22.
Please see attached screenshot. I am using the location field because that is the only one that has the display option. Although it would be great to have it with the node settings itself. Additionally, I have setup my Google Maps API key and jquery_ui module as well.

Thanks.

rooby’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev

Sorry, since this issue was originally posted for the drupal 7 version I thought it was the problem which is for all cck formatters that use gmaps in the drupal 7 version you only see this text:
"Javascript is required to view this map"

This is not the same problem as the issue you are seeing.
If you locations don't have latitude and longitude values a map will not display.
In your second screenshot this may be the case but in your original one there are coordinates so that is probably not it.

Off the top of my head I can't think of other reasons why this would happen.
I'll have to have a think.

I guess if you are comfortable editing code in your location_cck.module file, then in the function

function theme_location_cck_formatter_all($element) {

In between the lines (at the bottom of the function:

  $content .= theme_location_cck_field_map(array($location), $field);
  return $content;

Add the following lines:

var_dump('element');
var_dump($element);
var_dump('location');
var_dump($location);
var_dump('field');
var_dump($field);

Then go to your browser and view one of the problem nodes.
You should get a big message displaying a lot of text. If you don't try a refresh.
If you still don't let me know.
If you do get the text (you should), can you paste the text into a text file and attach here.

Then you can remove those lines you added to the code again.

Setting back to D7 as that was what the original post was for and patch is for.
I'll still try to sort out your problem though and if it turns out to be a bug we can open a new issue for the different problem.

youssefr’s picture

I apologize. Indeed, I did open this for 7.x-3.x-dev and I lost track. Sorry about that.
Now that #27 is confirming that the patch is working, any ideas or possibilities to have this committed.
Would you like me to send you my drupal 6 dev link via your contact form?
Thanks.

rooby’s picture

If you like I can have a look. I would need the required permissions for administering content types, creating or administering nodes, administering location & gmap although I can't promise being able to solve it as sometimes filesystem access and debugging is required.

rooby’s picture

For reference, the problem youssefr was seeing was not a bug and has been resolved.

rooby’s picture

Status: Needs review » Fixed
youssefr’s picture

Thanks rooby.

Status: Fixed » Closed (fixed)

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

emettler’s picture

I'm having this problem and what is odd is that it was working for location CCK - and now it is not. A map will display for a node location in a block but that's not really what I need. Anyone else? Any suggestions?