a is null

...c,180));e=Fd(o[Cc](e/f));return new ge(new P(d,a.lng()-e),new P(c,a.lng()+e))};f...

{main,places}.js (line 32)

doesnt work any js on node edit/create form, also, the map is not displayed.

CommentFileSizeAuthor
#4 getlocations_js_error-1409186-4.patch382 bytesimclean

Comments

dgastudio’s picture

the above error appear in firebug /firefox

in chrome console appear:
%7Bmain,places%7D.js:32Uncaught TypeError: Cannot read property 'offsetWidth' of null

hutch’s picture

try switching off markermanager

dgastudio’s picture

Status: Active » Closed (works as designed)

yep, now it's working. thanks

imclean’s picture

Status: Closed (works as designed) » Needs review
StatusFileSize
new382 bytes

I'm not sure it really "Works as designed" if a feature needs to be turned off. Either way, my solution was a little different.

I was seeing the "a is null" error in Firefox but the map was displaying as expected in the generated block. The error was interfering with jcarousel and causing it to not function at all.

new google.maps should be fired on $(document).ready() so I've wrapped the call to initialize().

hutch’s picture

Issue tags: +jQuery

Yes, "Works as designed" is not the best way to describe a feature that does not behave ;-)

The Markermanager software is third-party though and has been troublesome in other, non-drupal scenarios. It also is not fully usable as each marker should have a zoom level associated with it.

I have been playing with MarkerClustererPlus which looks much more promising, it is in the latest dev.

My understanding is that the $(document).ready() ..... ); construct has been replaced with (function ($) { ..... })(jQuery); which is present, the whole of getlocations.js is wrapped in it.

I will try to reproduce the error with jcarousel and see what happens.

imclean’s picture

My understanding is that the $(document).ready() ..... ); construct has been replaced with (function ($) { ..... })(jQuery); which is present, the whole of getlocations.js is wrapped in it.

Ah yes, that's what the attach bit is for. It does seem odd that it fires off an error but the map still works.

Chrome:

Uncaught TypeError: Cannot read property 'offsetWidth' of null (main.js:30)

- jcarousel fields view in the first sidebar
- Location field stores lat/long
- "View: Getlocations map of a location" block displays map in content area

Problem:

- jcarousel View is an unstyled list of fields with no js.

The patch in #4 makes sure the DOM is full loaded first, but I guess this could be hiding another problem.

imclean’s picture

It's also seems to kill other js on the page: admin_menu and megamenu in my case.

imclean’s picture

I can't get this to work with any other js in the latest dev.

As a test, I added an alert:

  // gogogo
  Drupal.behaviors.getlocations = {
    attach: function() {
      alert('hello');
      initialize();
    }
  }; 

When then alert pops up no other js has been loaded, after clicking "ok" nothing works apart from getlocations.

With $(document).ready:

  // gogogo
  Drupal.behaviors.getlocations = {
    attach: function() {
      $(document).ready(function() {
        alert('hello');
        initialize();
      });
    }
  };

js has been loaded by the time the alert pops up (jcarousel lists are styled). After clicking OK, everything works as expected despite the "a is null" error still appearing. This includes jcarousel, admin_menu and megamenu.

The attach doesn't seem to be waiting for other js to be loaded.

hutch’s picture

The "a is null" error comes from Google maps (I think). Switching off Markermanager would eliminate it for now. By the way I have now got support for Marker Clusterer which seems a lot better.

I'm looking at the details of how drupal adds js at the drupal_add_js API page.

getlocations.js is loaded in function getlocations_setup_js() in getlocations.module starting on line 696
It might be possible to give it "weight" or load it in footer

Why 'attach' is jumping the gun I don't know, perhaps it isn't but needs to be loaded later or deferred

hmmm I changed

    drupal_add_js(GETLOCATIONS_PATH . '/js/getlocations.js');

to

    drupal_add_js(GETLOCATIONS_PATH . '/js/getlocations.js', array('weight' => 100));

Now it loads last.
Could you try that (line 768)?

imclean’s picture

Thanks for the help. I've tried adding getlocations.js with the scope of footer which puts it down the bottom to no avail. I'll try the weight option as well.

Markermanager is not enabled. The map still works, it just kills everything else. Even with my addition the error occurs but it allows the other js to function.

It's very strange, I'm not sure attach is a good replacement for $(document).ready() in all cases.

hutch’s picture

I installed admin_menu and jcarousel (and getlocations using getlocations_fields) and have all 3 working fine on the same page.
I am using jQuery Update...

imclean’s picture

I'm using location module but that shouldn't make any difference. I do still wonder whether the problem is elsewhere.

jQuery 1.5.2 is the version I'm on. Will keep digging.

imclean’s picture

Excellent, thanks hutch! The following does indeed work with our custom theme.

drupal_add_js(GETLOCATIONS_PATH . '/js/getlocations.js', array('weight' => 100));

This wasn't required when I tested with Garland. I had tried disabling all js and various stylesheest in our theme to no avail.

hutch’s picture

Status: Needs review » Closed (fixed)

Good! I will add this as a configurable option to the next push, probably later today.

dgastudio’s picture

argh.....

latest dev version for now.

enabled default view: Getlocations map

a is null
...this.d,b)};function Vg(a,b,c){if(a=a[Za](b))c=o.pow(2,c),a.x*=c,a.y*=c;return a}...
in
{main,places}.js line 32

i have disabled marker manager, cluster.

also, in views

NetworkError: 404 Not Found - http://medstream.krypton.vps-private.net/sites/all/modules/getlocations/...

hutch’s picture

The 404 Not Found has been fixed a just a few hours ago. I haven't been able to replicate the 'a is null' error.
You could try setting Getlocations Javascript weight in admin/config to 100, some themes seem to have a problem.

dgastudio’s picture

ok, i'll wait a new release.

changing weight in admin config to 100, causes

a is undefined
...this.d,a)};var Pe="click",Qe="contextmenu",Re="forceredraw",Se="staticmaploaded"...
{main,places}.js (line 21)

a is null
(181 out of range 48)
{main,places}.js (line 181

can u take a look, please?
http://medstream.krypton.vps-private.net/catalog/institutions/medicinsko...

the map must appear in middle column

(i have removed weight for now.)

dgastudio’s picture

i'm testing in firefox, doesnt work.

in chrome, the error is a little bit different

Uncaught TypeError: Cannot read property 'offsetWidth' of null

hutch’s picture

Google maps is not happy with something, probably another javascript.

imclean’s picture

I was still having problems with Megamenu not working on getlocations pages. The problem was megamenu.js using $(document).ready instead of Drupal behaviors.

Megamenu issue: #1458084: Use Drupal behaviors instead of $(document).ready()

hutch’s picture

Sorted!

dgastudio’s picture

look, this is default getlocations view

http://medstream.krypton.vps-private.net/getlocations_all

it's works on all pages except on content type display

works
http://medstream.krypton.vps-private.net/consultation/vopros-0

doesnt work
medstream.krypton.vps-private.net/catalog/institutions/medicinskoe-uchrezhdenie

it's the same js, loaded for all pages..

dgastudio’s picture

it's ok.

clean installation of drupal

content type: test
- getlocations fields

views: getlocations all
- block
- Show map even if view has no results
- place block in any region.

create new node of content type test. fill getlocations fields. save

a is null

REMOVE getlocations fields from TEST content type.

go to previously created node.

the map works!

broon’s picture

I am now experiencing this error. I am using getlocation-1.1.
There is a content type with getlocations fields and an image field (with unlimited values). Everything works fine, I can add locations to map and upload images. But when I want to delete one image from the list on the node edit page, I hit the remove button and nothing happens.

The error message from Chrome:

Uncaught TypeError: Cannot read property 'offsetWidth' of null
Zg%7Bmain,places%7D.js:29
yh%7Bmain,places%7D.js:36
batchrgetlocations.js:215
b.extend.eachjquery.js:33
initializegetlocations.js:24
Drupal.behaviors.getlocations.attachgetlocations.js:523
Drupal.attachBehaviorsdrupal.js:55
b.extend.eachjquery.js:33
Drupal.attachBehaviorsdrupal.js:53
Drupal.ajax.commands.insertajax.js:542
Drupal.ajax.successajax.js:400
Drupal.ajax.ajax.options.successajax.js:164
b.fn.ajaxSubmit.a.successjquery.form.js:12
sjquery.form.js:12
b.fn.ajaxSubmit.window.(anonymous function)jquery.form.js:12
(anonymous function)edit:1
onload

Error message from Firefox:

a is null
http://maps.gstatic.com/cat_js/intl/en_ALL/mapfiles/api-3/9/1a/%7Bmain,places%7D.js
Line 29

I disabled "Use marker manager" option. Still the same as above.

Then I set the javascript weight to 100 as suggested. The node edit page no longer shows the map and the error changed.

Chrome

Uncaught TypeError: Cannot call method 'panTo' of undefined
updateMapgetlocations_fields.js:298
Drupal.behaviors.getlocations_fields.attachgetlocations_fields.js:45
b.extend.eachjquery.js:33
Drupal.behaviors.getlocations_fields.attachgetlocations_fields.js:18
Drupal.attachBehaviorsdrupal.js:55
b.extend.eachjquery.js:33
Drupal.attachBehaviorsdrupal.js:53
Drupal.theme.placeholderdrupal.js:391
b.extend.readyjquery.js:30
u

Firefox

umap is undefined
http://mydomain.com/sites/all/modules/getlocations/modules/getlocations_fields/js/getlocations_fields.js?m4xknz
Line 298

I tried other weights as `1` and `-1` to no avail.

hutch’s picture

Status: Closed (fixed) » Needs review

Try the current dev, it might not fix it but it might behave a bit better.
Please let this thread know what happens.

dmitrii’s picture

Last dev (2012-Jul-14) fixed the problem with file upload/remove with get location field enabled for me.
Thank you.

pikot’s picture

In my case, this error appears when I update the module Search Autocomplete, and none of the solutions above worked for me. Disabling the module Search Autocomplete, the errors disappeared and the map showed again...

hutch’s picture

I downloaded search_autocomplete-7.x-2.4.tar.gz, installed it on a test rig, configured and enabled the search block, it searches with autocomplete just fine, then went to a node with a map (plus another map in the sidebar showing places nearby) all maps working, no js errors, then tried getlocations search page, that's OK, then tried input map in a new node, no problem at all.
So I cannot reproduce this error ;-(

pikot’s picture

In my case search block works with autocomplete too, but it disables all the other javascript on the page an show the "a is null" error. Everything works again if I uninstall the Search Autocomplete. Very strange...

hutch’s picture

Status: Needs review » Closed (fixed)