My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 2148: event.latLng Missing!
9 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Feb 2010


Sign in to add a comment
 
Reported by [email protected], Feb 3, 2010
Recently the event.latLng changed name to event.Hk, this messes up alot och
code!
Feb 3, 2010
#1 [email protected]
I have done some digging and found that the event.latLng is present when the listener
is attached to the map, but if it is attached to a polygon the event.latLng will be
replaced with a event.Hk object.
Feb 10, 2010
#3 [email protected]
is it permanent ?
Feb 10, 2010
#4 [email protected]
Well its a permanent error for me.
Feb 10, 2010
#5 [email protected]
Bit of a annoyance this one, definitely seems to affect click events generated by
polygons, markers and map are unaffected as far as I can tell, be nice to know why
it's changed if it's going to be permanent as it's not in the changelog or if it's
just a simple mistake. 
Feb 15, 2010
#6 [email protected]
it works for markers but not for infowindows etc.
I mean you can put a marker on event.latLng but you can't put a infowindow on
event.latLng...
Feb 19, 2010
Project Member #7 [email protected]
(No comment was entered for this change.)
Status: FixedNotReleased
Labels: Internal-2420976
Feb 24, 2010
#8 [email protected]
Seems to be "event.Qi" for markers right now...
Feb 26, 2010
Project Member #9 [email protected]
(No comment was entered for this change.)
Labels: Fixed-29
Feb 26, 2010
Project Member #10 [email protected]
(No comment was entered for this change.)
Status: Fixed
Apr 22, 2010
#11 [email protected]
It still doesn't work for me. My code is simple:

					var listener = google.maps.event.addListener(marker,'click',function(event)
							{
							
							var theHtml = $('markerOptions').innerHTML;
							var infowindow = new google.maps.InfoWindow({ content:theHtml });
		
							alert(event.latLng)
	    					theHtml = theHtml.replace('%LAT%', event.latLng.lat() );
							theHtml = theHtml.replace('%LNG%', event.latLng.lng() );
							map.setCenter(event.latLng);
		
							infowindow.setContent(theHtml);
	    					infowindow.setPosition(event.latLng);

							infowindow.open(map,marker);
			
								
							});

the event.latLng is undefined.
Sep 6, 2010
#12 [email protected]
me too, event.latLng
im using this api
http://maps.google.com/maps/api/js?sensor=false

maybe a specific version will work?

Sep 6, 2010
Project Member #13 [email protected]
Instead of accessing event you will want to access this.getPosition() so:

var listener = google.maps.event.addListener(marker,'click',function() {
  var theHtml = $('markerOptions').innerHTML;
  var infowindow = new google.maps.InfoWindow({ content:theHtml });
  var position = this.getPosition();
  theHtml = theHtml.replace('%LAT%', position.lat() );
  theHtml = theHtml.replace('%LNG%', positon.lng() );
  map.setCenter(positon);
		
  infowindow.setContent(theHtml);
  infowindow.setPosition(position); // You don't need this line because the one below overwrites it.
  infowindow.open(map, this);
});
Sep 6, 2010
#14 [email protected]
but, why api reference still saying that event.latLng is available?
Sep 6, 2010
Project Member #15 [email protected]
The reference for the click event on a marker (https://code.google.com/apis/maps/documentation/javascript/reference.html#Marker) says the arguments are an Event, not a MouseEvent.

Only drag, dragend and dragstart are MouseEvents.
Sign in to add a comment

Powered by Google Project Hosting