0

In my drupal 6 site, I use finder embedded in a node, to search for another node.
When user select a result the node is loaded in the same page.
The final structure is

  • parent node
    • finder embedded
    • parent node description
      • resulting node

Everything works fine, except that the Map loaded in the resulting node is not displayed.
I get this error "Javascript is required to view this map".
Obviously I've checked what's wrong, and I've seen that the required JS are missing (gmap.js, marker.js, etc..).

How can I force GMap to load js if they are missing?
Why do you think this is happening?

UPDATE

The problem is related to Ajax. If I take the same scenario and hit Enter instead of Find, the request is made without using Ajax and the map is shown correctly.
Using the Find button (Ajax request) the problem persist.

Any solution?

1
  • Which Drupal version do you use? And can you tell us how the resulting node is loaded? Do you have multiple nodes like the parent node, or is it there just one on your site? Commented Jul 27, 2011 at 6:07

2 Answers 2

1
+25

GUnload is part of the Gmap API. Are you loading the Gmap js files served by Google?

The error would happen if the JS file from Google is:

  • Missing.
  • Has not been parsed when the code giving the error is executed.

To give a more thorough answer more details are needed.

Update

The Gmap module is a bridge to the Gmap JS API that Google has created. The actual Gmap JS API is not included in the module itself but is served by google. It's included using the following line:

drupal_set_html_head('<script src="'.
  check_url(url('http://maps.google.com/maps', array('query' => $query))).
  '" type="text/javascript"></script>'
);

The error you are getting, it is caused by the lack of the above JS file, or because it's loaded after the gmap module JS code is run.

6
  • No, the files are the one included in the GMap module. drupal.org/project/gmap
    – pasine
    Commented Jul 29, 2011 at 8:36
  • @notme You are wrong, see my updated answer.
    – googletorp
    Commented Jul 29, 2011 at 9:52
  • where should this be added? into template.php or in the tpl file?
    – pasine
    Commented Jul 29, 2011 at 11:08
  • @notme It should be added to the head of the site along with other JS and CSS file declarations. See drupal_set_html_head
    – googletorp
    Commented Jul 29, 2011 at 11:10
  • I've tried, but I get a syntax error in maps.
    – pasine
    Commented Jul 29, 2011 at 11:28
1

I think you should force gmap to include JS in your parent page (or, to test, every page). Insert this in your hook_init() or in your template.php:

_gmap_doheader();

The reason is that, if you include JS by AJAX, it may be not ready when Gmap uses it.

Edit: I looked at the code again, and changed the code.

5
  • hook_init should be in my template.php file?
    – pasine
    Commented Jul 29, 2011 at 11:09
  • I've changed the code. You can put in your theme (preprocess_page) or hook_init of a module. Check api.drupal.org/api/drupal/includes--module.inc/group/hooks/6 for what is a hook.
    – jcisio
    Commented Jul 30, 2011 at 6:55
  • I think in this way the js are correctly loaded, but I still get "GUnload is not defined" pointing at this "if (Drupal.jsEnabled) { $(document).unload(GUnload); }"
    – pasine
    Commented Jul 30, 2011 at 10:37
  • Ok, the problem with GUnload was I modified the GMap module. Reinstalling the -dev version made the error disappear. But the map still doesn't show.
    – pasine
    Commented Jul 31, 2011 at 16:46
  • The problem is not related to JS, but to Ajax request. I've updated my post with more details.
    – pasine
    Commented Aug 1, 2011 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.