Problem/Motivation

I'm using the location_node module to assign a location to each of the event nodes on my site. The events can happen anywhere in the world. I've noticed that if I enter in an address with the default, pre-selected country (UK), and then click on the 'find address on map' button, then the geocoding works. If, however, I change the country to say US, and enter in a US address, then the 'find address on map' button no longer works. Even if I return to the UK setting and re-enter the UK address, it still doesn't work. I have to save the node, re-edit and then click on the 'find address on map' button again.

Basically the 'find address on map' button only works for the country populated in the form on initial page load, as soon as you change the country, the geocoding stops working.

I'm wondering if Drupal behaviours need to be re-attached or something? but don't rightly know.

Comments

josebc’s picture

+1 having same issue, any luck ?

josebc’s picture

Project:Location» GMap Module
Version:7.x-3.0-rc1» 7.x-2.7

moving to gmap

Arrow’s picture

I am also seeing this issue. A javascript error occurs when clicking the "Find Address on Map" button.

TypeError: m.change is not a function
http://www.example.com/sites/all/modules/gmap/location_gmap_find_address...
Line 27

Arrow’s picture

Seems the Drupal.gmap.getMap(gmap_id) function is returning false rather than an object. This normally works, but once you change the country, it loses the ability to find the map. Not sure why though.

balajidharma’s picture

+1 having same issue.

m33_nft’s picture

+1 We have to go into editing again, and press the find adress on map

podarok’s picture

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

moving to dev

m33_nft’s picture

Hey guys I have a stupid decision (since I know nothing about js)
First, use default counry, in select list

just add before $("button.location-gmap-find-address-button").click(function (e) {

$( document ).ready(function() {
               
                $("button.location-gmap-find-address-button").click();
            });

and replace code into "if (status == google.maps.GeocoderStatus.OK) {"

var m = Drupal.gmap.getMap(gmap_id);
                            if (typeof m === 'object')
                            {
                             
                                m2 = m;
                                m.locpick_coord = results[0].geometry.location;
                                m.change('locpickchange');
                                m.map.setCenter(results[0].geometry.location);
                                m.map.setZoom(14);
                            }
                            else
                            {
                                m2.locpick_coord = results[0].geometry.location;
                                m2.change('locpickchange');
                                m2.map.setCenter(results[0].geometry.location);
                                m2.map.setZoom(14);
                            }

Sorry for stupid code, but my content-manager can work now )) good luck
Waiting for real fix =)

madhusudanmca’s picture

Hi All,

The trick to wrap the click "$( document ).ready();" worked for me as described in comment #8 by m33_nft. However no need to go for second trick given there, it may cause more errors.

Thanks m33_nft for giving trick!!

m33_nft’s picture

Any news? When will the fix?

yaelsho’s picture

Hello,
I complete the change per m33_nft suggestion which fixed the 'find address on map' button malfunction issue.
I had to put both parts in order to make it work.

p.s. before I made the fix per #8 the 'find address on map' stop working post any ajax activity, e.g- changing country= ajax to find the new province list, upload image = ajax loading. Now after the change the 'find address on map' button works post both of them.

The issue with this fix is that every time you are editing the node with location field, or every time you upload new image, it reset the coordinator chooser. Which is unwanted affect in case the user already define the exact coordinates he want, he will lose it and need to redefine them every time he would like to edit his content.

Since I couldn't find better solution, I had to disable this great feature.
Thanks, Yael