Yahoo Maps AS3 Communication tool kit

I am playing with the Yahoo Maps communication tool kit since it has released and I was pretty disappointed on seeing that it doesn’t had the CustomPoiMarkerClick event.

Then I started looking in the code which is relased by yahoo maps as a wrapper to the existing Flex 1.5 API

I have just modified the method in that source and i am posting it here so it might be useful to ppl working on Mashups.

function onPOIClicked(ev:Object) {
var rtnObj:Object = new Object();
var myMarker:Object = ev.marker;
for (var p in myMarker) {
rtnObj[p] = myMarker[p].toString();
for (var q in ev){
if (typeof(ev[q]) != 'movieclip') {
rtnObj[q] = ev[q];
EIBuffer.addCall({method:swfDomId + ".onPOIClicked" + id, data:rtnObj});

After changing the method in the as2map.fla file which is under source/as2 directory of yahoo library source.

I was able to get all the marker details like ‘title’, ‘description’,’index’ and the usual stuff like latlon information etc.

Hope that helps,



9 Responses to “Yahoo Maps AS3 Communication tool kit”

  1. March 25, 2007 at 9:06 am

    The docs are weak in this regard. For the following, code how should the “ev” variable be referenced to get back the point of interest data?

    private function onPOIClicked(ev:Object):void
    title.text = ev.???;

    What is the object reference supposed to be in this case above?

    As a bonus, I have included below a snippet of something that should have been easy to figure out had the docs been more complete:

    private function onMapClick(ev:MapEvent):void
    var llpat:RegExp = /point\((.*)\,(.*)\)/i;
    var rs:String;
    var ro:Object;

    rs = ev.lastResult.latlon;

    if ( llpat.test(rs) == true )
    ro = llpat.exec(rs);
    selLatitude = ro[2];
    selLongitude = ro[1];

    latitudevalue.text = selLatitude.toString();
    longitudevalue.text = selLongitude.toString();

    var myMarker:Object = {index:’M!’, title:’My Mark’, description:’This is a marker!\nIt is located here.’, markerColor:0x999900, strokeColor:0xFF00FF};

    latLonController.addMarkerByLatLon(‘CustomPOIMarker’, selLatitude, selLongitude, myMarker);
    //latLonController.addMarkerByLatLon(”,selLatitude, selLongitude, {waypointIndex:’M’});

    Note that there is probably a better way to access the latlon variable. I found no meaningful examples describing this.

  2. March 26, 2007 at 6:25 am

    Hi Mario,
    Can you please elaborate more on this..
    As per my understanding the following loop does the trick as title and all other information about point of interest data is stored in the marker object and you can get the marker object and all the properties of the marker object by this loop ..

    for (var p in myMarker) {
    rtnObj[p] = myMarker[p].toString();

    So you will be able to get the latitude and longitude information using the rtnObj
    Hope that Helps,

  3. March 26, 2007 at 1:16 pm

    I was able to answer my own question for het POI issue. The answer to that was:


    I wanted to know the dotted notation, rather then the generic array ref approach.

    I still don’t know what the dotted notation for the latlon should be for an event such as:


    The object type is “point”, but nowhere is it described that I was able to unearth. My solution for referencing it was dumb, but I was in a rush.

    Thanks for your input.

  4. 4 G
    April 4, 2007 at 3:51 pm

    Hey guys,

    I’m using Flex 2, and trying to use Yahoo’s new AS3 Maps libraries. I am trying to place a marker on the map wherever and whenever a user clicks on the map. I am getting some strange behavior from the addMarkerByLatLon function. Hope you can help me out 🙂 Below is some of my code:

    //these two lines are called when the map initializes
    var d:MapEventDispatcher = new MapEventDispatcher(myAS2Map);
    d.addEventListener(‘onClick’, onClick);

    //this is my onClick function
    private function onClick(ev:MapEvent):void{

    var llc:LatLonController = new LatLonController(myAS2Map);
    var point:Object = {latitude:ev.lastResult.latlon.x, longitude:ev.lastResult.latlon.y};

    var latNum:Number = new Number(point.latitude);
    var lonNum:Number = new Number(point.longitude);

    llc.addMarkerByLatLon(‘WaypointMarker’, latNum, lonNum, ”);

    Alert.show(“Lat: ” + point.latitude + ‘\n’ + “Lon: ” + point.longitude + ‘\n’ + “Latx: ” + ev.lastResult.latlon.x + ‘\n’ + “Lony: ” + ev.lastResult.latlon.y);


    When a user clicks on the map, the alert displays the correct latlons.
    The first time a user clicks on the map, a marker is placed, but only at the center. For any subsequent clicks on the map, the Alert displays the correct latlon but no marker is displayed!

    What could I be missing? Your help would be much appreciated!

  5. 5 Thousand
    July 27, 2007 at 4:20 am

    Thank you so much for this *minor* alteration! I’ve just finished trying everything I could to grab the title property, and was about to give up. It’s comforting to know the value wasn’t available in the first place 🙂

  6. July 27, 2007 at 6:34 am

    Thanks Thousand for your comment

  7. 7 Evelynn
    November 27, 2007 at 8:28 pm

    I’m making cyclingapplication in FLEX2.
    I’m trying to add a marker by latlon on a map.

    The latitude and longitudes are in a xml file (database driven).
    this what it should be.

    the truyth is that I can’t manage to add a markerby latlon on the map with de latlon given in the string.
    –> latLonController.addMarkerByLatLon(“WaypointMarker”, 51.265960, 3.034449);

    can someone help me with the code? can someone help me with adding an entire route with markers on a map?

    please help

  8. January 6, 2008 at 11:26 pm

    very interesting.
    i’m adding in RSS Reader

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Its Me

March 2007
    Apr »


Blog Stats

  • 10,473 hits

My Links

Amazon Wish List

My Amazon.com Wish List

%d bloggers like this: