Home > Flash development > Yahoomaps latlon example

Yahoomaps latlon example

March 24th, 2006 Randy

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 Tags:
  1. March 28th, 2006 at 18:37 | #1

    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

  2. Randy Troppmann
    March 29th, 2006 at 21:49 | #2

    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?

  3. May 15th, 2006 at 23:34 | #3

    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?

  4. Randy Troppmann
    June 13th, 2006 at 09:27 | #4

    Sorry Andrew. I don’t know.

  5. John Kirby
    October 9th, 2006 at 10:05 | #5

    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?

  6. Randy Troppmann
    October 13th, 2006 at 09:41 | #6

    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.

Comments are closed.