Yahoomaps latlon example
March 24th, 2006
My mashup RUNINGMAP.COM uses the YahooMaps web service as the source for its maps. There has been some interest in the YahooMap developer community regarding how I was able to pull out the latitude and longitude values so I can make my distance calculations. He is an example of how I do it. You can download the source code here.
UPDATE: The attached FLA contains what is by now a legacy version of the Y! Maps component in the library so it may cause errors if you try to compile it. Be sure to download the latest version and install it in Flash. Then refresh the version in the library with the new version.
Categories: Flash development

thanks for posting the source code! I’m slighty new to the ymap as business, and I was wondering if you could tell me what the line:
var latLon:LatLon = yahooMap.map.map_3.getLatLon(mapPoint);
is doing. is there a way to change the map_3 parameter dynamically to allow for this to work at various zoom levels? Is the getLatLon method an unexposed part of the api? Thanks for any help, and keep up the sweet work… will
Great idea! Yes you can dynamically assign the map like this:
var latLon:LatLon = yahooMap.map["map_" + zoom].getLatLon(mapPoint);
Zoom is a variable where you are keeping track of the zoom level.
Yes, this is an undocumented call. Does this answer your question?
Is it possible to use this technique in combination with a CustomSWFOverlay when using the JS-Flash API? I’m trying to find a way to allow users to click on a map, automatically creating a marker, returning the lat/lon. Any ideas how to accomplish this?
Sorry Andrew. I don’t know.
This is great… except I’m getting an undefined (when I execute the click) LatLon (yes I’m importing the com.yahoo.maps.LatLon) on the myMap.map.map_3.getLatLon(myPoint)?
I am getting x,y values from the previous call new Point(myMap._xmouse, myMap._ymouse)
Any Ideas?
What zoom level are you viewing at? myMap.map.map_3.getLatLon(myPoint) assumes you are on zoom level 3. Example:
myMap.map.map_%.getLatLon(myPoint)
where % = current map level.
Note that this is undocumented and not part of the offcial “API”, but it works.
I hope that helps.