Reputation: 4519
I am trying to migrate my existing working Google Map code into Javascript Object Based fashion, But I am running into some error, not able to figure it out .Initially all markers are loaded, and on any events (click, drag etc) its throwing the error TypeError: g.j is undefined.
I guess below lines are the cause of error:
google.maps.event.addListener(mapObj.polymap, "dragend", mapObj.mapSearch());
google.maps.event.addListener(mapObj.polymap.getPath(), "insert_at", mapObj.mapSearch());
google.maps.event.addListener(mapObj.polymap.getPath(), "remove_at", mapObj.mapSearch());
google.maps.event.addListener(mapObj.polymap.getPath(), "set_at", mapObj.mapSearch());
Upvotes: 0
Views: 916
Reputation: 117354
the 3rd argument of google.maps.event.addListener
is expected to be a function, but you provide function-calls, not functions.
You must remove the parentheses after the function-name:
google.maps.event.addListener(mapObj.polymap, "dragend", mapObj.mapSearch);
google.maps.event.addListener(mapObj.polymap.getPath(), "insert_at", mapObj.mapSearch);
google.maps.event.addListener(mapObj.polymap.getPath(), "remove_at", mapObj.mapSearch);
google.maps.event.addListener(mapObj.polymap.getPath(), "set_at", mapObj.mapSearch);
//.................
google.maps.event.addDomListener(window, 'load', mapObj.init);
Upvotes: 3