a.lng is not a function

2,017 views
Skip to first unread message

midimid

unread,
Mar 16, 2010, 4:29:30 PM3/16/10
to Google Maps JavaScript API v3
Continuing my experience with overlay and projection.

I have a custom overlay class and have made sure that the projection
is retrieved only after onAdd. The projection is placed in a var
available. None of my script runs until onAdd has been called.

Much much later in my scripting I have the following code that is
throwing the error:
Error: a.lng is not a function
Source File: http://maps.gstatic.com/intl/en_us/mapfiles/api-3/0/33/main.js
Line: 33

function setMarkers() {
for (var markerIndex in markers) {
var marker = markers[markerIndex];
var position = marker.getPosition();
var lat = position.lat();
var p1 = proj.fromLatLngToDivPixel(lat);
}
}


Note that I'm not even calling for longitude. If I comment out the var
p1 line, everything works fine. I've also confirmed that proj, lat,
position, and marker are not undefined.

Chris Apolzon

unread,
Mar 16, 2010, 4:47:48 PM3/16/10
to google-map...@googlegroups.com
Looks like the latLngToDivPixel method takes in a point (a latLng object) so try passing position in instead of lat.


--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Ben Appleton

unread,
Mar 16, 2010, 5:02:38 PM3/16/10
to google-map...@googlegroups.com

Sure, but why do you pass a function called fromLatLngToFoo only a lat?  As the name (and docs) suggests it requires a LatLng.

midimid

unread,
Mar 16, 2010, 5:26:59 PM3/16/10
to Google Maps JavaScript API v3
Stupid logic error on my part - apologies and thanks!
Reply all
Reply to author
Forward
0 new messages