I'm attempting to show a map from a Location Field on a node details page, and receiving the dreaded "Javascript is required to view this map" error regardless of whether I'm using Safari or Firefox or whether I'm logged in or not. Also, I don't have "Aggregate JavaScript files" set, and toggling that setting doesn't appear to have any effect.

I did a view source on the page and I have noticed that the "gmap_markers.js" is not listed in the script imports.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jarode’s picture

Same issue. :-(

aqua_linksunten’s picture

Hi, I have the same problem. I looked a bit in the gmap.module-file and noticed that in there a gmap-markers.js is referred to instead of the gmap-marker.js-file

najibx’s picture

When I look at the page source, the gmap JS not even loaded. To prove this, I added the following inside , in my case .. in modules/system/html.tpl.php (never hack the core, this is just for test). So must be a bug somewhere ...

  <script type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2.115&amp;key=ABQIAAAA-w3MtaTs49QtWIZqK8SbLhQGxLbSA2kYCtBlZARQz6FoXh2UmBRbY-40mbeHjjXclsaFc6r6f4_3yg&amp;hl=en"></script>
<script type="text/javascript" src="/sites/all/modules/gmap/js/gmap.js?lh4u2w"></script>
<script type="text/javascript" src="/sites/all/modules/gmap/js/icon.js?lh4u2w"></script>
<script type="text/javascript" src="/sites/all/modules/gmap/js/marker.js?lh4u2w"></script>
<script type="text/javascript" src="/sites/all/modules/gmap/js/highlight.js?lh4u2w"></script>
<script type="text/javascript" src="/sites/default/files/js/gmap_markers.js"></script>
<script type="text/javascript" src="/sites/all/modules/gmap/js/markerloader_static.js?lh4u2w"></script>

<script type="text/javascript" src="/sites/all/modules/gmap/js/gmap_marker.js?lh4u2w"></script>
<script type="text/javascript" src="/sites/all/modules/gmap/js/poly.js?lh4u2w"></script>

Agence Web CoherActio’s picture

subscribing

JimR’s picture

Having the same issue :(

Renegadez’s picture

++

rofsky’s picture

same

fuse’s picture

subscribing

Javascript files are not beeing added inside <head></head>. Adding them to html.tpl.php manually like Najibx suggested works, but of course this is not the right way to solve this bug.

litzastark’s picture

To do this without hacking core, try adding this code to your template.php:

function template_preprocess_page(&$variables) {
  drupal_add_js('http://maps.google.com/maps?file=api&v=2.115&key='.variable_get('googlemap_api_key').'&;hl=en');
  drupal_add_js(drupal_get_path('module', 'gmap').'/js/gmap.js');
  drupal_add_js(drupal_get_path('module', 'gmap').'/js/icon.js');
  drupal_add_js(drupal_get_path('module', 'gmap').'/js/marker.js');
  drupal_add_js(drupal_get_path('module', 'gmap').'/js/highlight.js');
  drupal_add_js('/sites/default/files/js/gmap_markers.js');
  drupal_add_js(drupal_get_path('module', 'gmap').'/js/gmap_marker.js');
  drupal_add_js(drupal_get_path('module', 'gmap').'/js/poly.js');  
}

This worked for me, at least!

zabelc’s picture

Actually, I just happened to realize: the map appears just fine for me when when I'm editing a node and when I have a GMap View.

This leads me to conclude that the gmap_markers.js isn't being added to the node view.

Anyone know which file controls that?

elgandoz’s picture

subS

tbenice’s picture

same problem, subscribing.

tbenice’s picture

I think this is the problem: for some reason all js injections were removed or commented out of the 7.x-dev version.

1) js is injected in _gmap_doheader() and it's commented out.

2) js is added in gmap_gmap pre-render $op and it's not there. I added it back in and it works. I'm not sure if the maintainer is planning to put it in the _gmap_doheader() function instead, but i've provided a patch in case this is ok.

-Ted

JVA-1’s picture

Status: Needs review » Active

Patch #13 fixed the problem on D7, thanks

tbenice’s picture

Status: Active » Needs review

will this work for dev?

zabelc’s picture

Status: Active » Needs review

It worked for me on 7.x-1.x-dev.

tbenice’s picture

Status: Needs review » Reviewed & tested by the community
bryancasler’s picture

subscribe

bryancasler’s picture

#13 works

rlangille’s picture

I can confirm #13 works on a vanilla install with dev.

Update: Note, this will fail if you are using multi site installs, as the patch points at default files instead of the site's files.

You may wish to change

drupal_add_js('/sites/default/files/js/gmap_markers.js');

to

drupal_add_js(variable_get('file_public_path', conf_path() . '/files') . '/js/gmap_markers.js');

At least until a better solution is found.

basicmagic.net’s picture

subscribe

elgandoz’s picture

#13 works for me on GMap 7.x-1.x-dev (2011-Mar-11). Thanks!

thetruthkc’s picture

Thanks #13 worked for me.

for the newbies (like me), i had to patch from the gmap directory, not the root install directory as suggested by http://drupal.org/patch/apply

patch -p0 < gmap_javascript_is_required_1061444.patch

botanist’s picture

Subscribing...#13 did not work for me unfortunately. Ran the patch as #23 suggested and all js files appear in source (and are accessible through the browser). Not sure what else could be wrong. Updated to the April 1st 7.x-1.x-dev version and no luck.

vodkov’s picture

#13 worked for me! Thanks.

zabelc’s picture

I updated the tbenice's patch from #13 to per the multi-site instructions offered by rlangille in #20. This version is attached for review.

Though I don't have a multi-site install, it seems to work for me. Any chance we can get this rolled into the dev branch soon?

@botanist, you might try clearing your site's cache a couple times (I saw another post that mentioned that one clear might not be enough so I always do it twice if only for the sake of superstition).

phayes’s picture

subscribe

gg4’s picture

subbing

yaworsk’s picture

Confirmed that patch in #13 worked for me as well with rlangille fix for multisite (huge thanks to you both!)

for reference, I was having the problem on profile pages created with the profile2 module.
pete

movemaine’s picture

More oddness - I get this same error unless I enable a Location block. And then the map shows in the block and in the content.

NathanM’s picture

Subscribing.

betarobot’s picture

#26 worked for me just perfectly. Thanks! Hope to see it committed soon.

Technonow’s picture

13 worked for me EXCEPT it works and I can view maps and markers when I am viewing as a visitor and NOT logged in!

When I log in, maps and markers disappear and I can only see "Javascript is required to view this map".

Anyone know the cause or can point me in the right direction please.

Using
Drupal 7.0-dev
Gmap 7x 1x-dev
Location 7x 3x-dev

lolmaus’s picture

Subscribing

Anonymous’s picture

I applied from #13 as well and now the map appears but I do get the marker.
I use:
gmap 7.x-1.x-dev from April 1st
location 7.X-3.x-dev from April 6th
I cleared the caches a few times and regenerated markers but no result.

robotcake’s picture

Subscribing

I as well don't get the marker

JulioGuedes’s picture

At first, i had applied patch #13, and it solved the message problem, but the markers didn´t work. But i deleted the module, installed it again and applied patch #26 and solved both problems. It´s working fine now! Thanks guys!

Anonymous’s picture

@JulioGuedes: thanks for the hint. I looked at both patches and went back to the gmap.module and manually changed the line with the gmap.markers.js code to the code as in patch #26 and it solved my marker problem as well (no need to uninstall and reinstall the module).
"drupal_add_js(variable_get('file_public_path', conf_path() . '/files') . '/js/gmap_markers.js');"

avizzino’s picture

Subscribing

Patch works, but I get the same problem with the marker!

Drupal 7.0
gmap 7.x-1.x-dev
location 7.x-3.x-dev

EDIT: #38 works well for me!
Thanks!

mrgoltra’s picture

sub.

mrgoltra’s picture

I got a Hunk #1 FAILED at 127 when I applied #13 patch. It seems to be working.

RCollins17’s picture

Unfortunately I am hosted on GoDaddy and they will not allow the patch command on shared servers. That said, where in the gmap.module would I copy the patch?

Thanks

mrgoltra’s picture

You can do it locally and upload the patched files

Link on how to apply patch on Windows (assuming you are using windows)
http://drupal.org/node/620014

celston’s picture

Subscribe. Patch from post #26 appears to work under core 7.0, GMap 7.x-1.x-dev (4/1/2011) and Location 7.x-3.x-dev (4/6/2011).

slackrunner’s picture

subscribing

Glottus’s picture

Great! #26 is really helping me now, thanks!

gooney0’s picture

Thank you. This patch worked for me using version gmap 7.x-1.x-dev (2011-Mar-31) and Drupal 7.2.

dimapv’s picture

I'm apply #13 patch - Gmap is appears, but markers was missed. I apply just 1 row from #26 patch with this: drupal_add_js('sites/default/files/js/gmap_markers.js');
but without the first '/' before 'sites'. All works perfectly.

RonP’s picture

So when fooling around with settings I got this error come up. Don't know if it helps.

Notice: Undefined index: revision table in field_views_field_default_views_data() (line 182 of /home/railrout/public_html/sites/all/modules/views/modules/field.views.inc).

Otherwise subscribe (-=

joelstein’s picture

#26 worked for me.

tahiticlic’s picture

I think this function should avoid to redeclare the js inclusions : _gmap_base_js

By the way, with JS aggregation, you should read this : http://drupal.org/node/1244314

bentleychan’s picture

subscribe

Summit’s picture

Subscribing, greetings, Martijn

coloryan’s picture

The patch in 26 worked for me, thanks zabelc.

thorprichard’s picture

From our troubleshooting of this nightmare, it appears that this bug in the Admin module may be the cause: http://drupal.org/node/969916
(Applying that patch was all that was needed to get gmap to correctly display in a view.) Your mileage may vary.

dimon00’s picture

Having the same problem on the last dev release.

The patch #26 doesn't seem to help.

The map is showing only with ajax disabled.

dorian_’s picture

Hi everybody,

modifying the gmap_markers.js in /sites/default/files/js and pointing to a custom marker-directory works fine.

Has anybody cleared the theme-cache after doing that?

It generates a new gmap_markers.js with the default path-settings :-(

Is there a way overriding a function and putting it to the template.php?

The following does NOT WORK:

function YOUR_THEME_NAME_gmap_regenerate_markers() {
	
  $contents = '';

  $contents .= "// GMap marker image data.\n";
  $contents .= "Drupal.gmap = Drupal.gmap || {};\n";
  $contents .= "Drupal.gmap.iconpath = " . drupal_json_encode(base_path() . variable_get('gmap_markerfiles', drupal_get_path('theme', 'YOUR_THEME_NAME') . '/markers')) . ";\n";
  $contents .= "Drupal.gmap.icondata = " . drupal_json_encode(gmap_get_icondata(TRUE)) . ";\n";

  $dir = "public://js/";

  // Make sure js/ exists in the files folder.
  if (file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
    $file = file_save_data($contents, 'public://js/gmap_markers.js', FILE_EXISTS_REPLACE);
    variable_set('gmap_marker_file', $file->fid);
  }
  else {
    drupal_set_message(t('GMap is unable to save the marker bundle. Markers will not work!'), 'error');
  }

  // Also regenerate the cached marker titles array
  gmap_get_marker_titles(TRUE);
}

Any ideas?

locavore’s picture

I ran into this problem (or at least a very similar problem telling me that Javascript is required to view the map) on a v7 site several weeks ago. I tried all of the recommendations shown in the posts above including disabling the various modules, patches, reconfiguration, uninstalled and re-installed, etc... and nothing helped.

Sent a note the help desk at my host (Hosting Metro). It took them about 10 minutes to fix and everything works perfectly now. It was a mod security setting..

Macronomicus’s picture

locavore ... did they tell you which mod security in particular?
Ive tried the patch in #26 and still cannot use ajax on a gmap view with filters.

jsj9832’s picture

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

Line 18:
Error: Object doesn't support property or method 'getPoint' for highlight.js.

It happens in IE8/9 when clicking on the markers.

Solved by in Gmap configuration. I unchecked Highligts in the Gmap settings page. Now my map is fully working.

haiiro.shimeji’s picture

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

@jsj9832
ok, it seems the different problem from in this thread, but about upgrading to API ver3.
I'll make the patch code in http://drupal.org/node/1586432, please try it.

swfindlay’s picture

I tried all sorts of solutions to this problem, and eventually came across this: http://drupal.org/node/1052372#comment-4392638

The solution is go to configuration>performance>enable and "Aggregate JavaScript files".

I hope this helps others! (It would've saved me 2 days!)

podarok’s picture

#26 commited to 7.x-2.x branch

thanks!

podarok’s picture

Status: Reviewed & tested by the community » Fixed
FileSize
1.41 KB

the same patch reroll to 7.x-1.x branch

fixed and commited / pushed to 7.x-1.x branch

Status: Fixed » Closed (fixed)

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

johnv’s picture

It seems this patch creates a problem. #13 's analysis may be wright, the solution may be wrong.
See my post with additional patch at #923630-29: Markers not showing up on Gmaps no matter what: How to debug

podarok’s picture

#66 looks like fixed/commited

RWill’s picture