Reputation: 14929
Here is the Listener I'm adding -
var map;
var geocoder;
function initialize() {
var myOptions = {
zoom: 8,
center: new google.maps.LatLng(22, 88),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
}
//google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.addListener(map, 'click', function(event) {
geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'latLng': event.latLng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
alert(results);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
});
But it is generating this error in console -
Uncaught TypeError: Cannot read property '__e3_' of undefined
Ke
Ie
R.addListener
(anonymous function)
Tried searching. But got no solution.
Upvotes: 29
Views: 39137
Reputation: 1612
In my case google.maps.event.addListener(marker, 'click', function() {
The marker variable was undefined. And hence the error. Might be useful for someone.
Upvotes: 0
Reputation: 668
Something like this?
var lati,longt; //contains latitude and longitude
func newLatLOng(){
get new value of latLong
initMap();
}
var map = 0;
function initMap() {
if (map ===0)
{
//load first time
lati= 28.5072216;
longt= 77.4971153;
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: lati, lng: longt},
zoom: 13
});
}else
{
var geolocation = { lat:lati,
lng: longt };
google.maps.event.trigger(map, 'resize');
map.setCenter(geolocation);
}
Upvotes: 0
Reputation: 157
In my case it was that the global map variable had been overwritten in the initializer but I wanted to use that global variable in another function and this caused the problem.
Upvotes: 1
Reputation: 1517
Yes, second that... The map variable must be declared outside and before its use. As the google maps listener cannot find it.
Upvotes: 0
Reputation: 301
I don't know if this may be an issue for you since we don't see the part of your code where you are linking to the google maps library, but I just discovered the reason I was getting this error was from trying to include the "visualizations" library. Luckily I didn't need to use it anymore.
I had this:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?libraries=geometry,visualization&sensor=true"></script>
and changed it to this:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?libraries=geometry&sensor=true"></script>
I no longer get the e3 error.
By the way, this error for me was not consistent and I could not figure out how to replicate it. I had to sit there and hit refresh over and over until the error occurred.
I hope this helps someone.
Upvotes: 2
Reputation: 700
This happens when loading your data asynchronous. You can avoid that by including your document.ready code into the ajaxStop function
$().ready(function() {
$(document).ajaxStop(function () {
/* your code here ?*/
});
});
Upvotes: 1
Reputation: 4622
It's hard to tell with only a small part of your code, but that sounds like it cannot find "map".
Either your map variable is not global, or somehow accessible by that code OR the map was not created with:
map = new google.maps.Map(....)
before you try and add a new click listener.
Upvotes: 9