Hello Ben,

Could you precise a little bit more what you want to do, and
particularly what you ExternalInterface expect to achieve ? Because on
any marker event, you have the marker in event.target so there is no
issue to identify a marker. And for looking for a specific marker that
would have a given user data (like a name) in a marker array, the
method given by RIck is ok. What you can also use is an associative
array in actionscript where the key is the marker and the value
another object, if you do not wnat to subclass marker. Like :

aMarker=new Marker(latLng);
myMarkersArray[aMarker] = myUserObject;

and when you want to get the user object for a given marker in an
event listener, you may do :

theUserObject = myMarkersArray[event.target as Marker];

or you can do the opposite where the user object is the key and the
markers are the value.


On 5 mar, 00:57, Bridh <[email protected]> wrote:
> Hello Rick,
>
> I see you have a good understanding of this problem,
> could you help me with my function.
>
> my objective is to have an externalinterface call back to the marker
> chosen.
> see here for example..http://booksdirtcheap.com/test/dcb-melb-locations.html
>
> problem is the marker last created gets displayed and i am unsure how
> to select the appropriate marker.
>
> Bridh
>
> function createMarker(latlng:LatLng, name:String, address:String,
> mon:String, tue:String, wed:String, thur:String, fri:String,
> sat:String, sun:String) {
>         var marker:Marker = new Marker(latlng, new MarkerOptions({
>
>         icon:new CustomIconSprite(),
>               iconAlignment: MarkerOptions.ALIGN_BOTTOM,
>             iconOffset: new Point(-11,0),
>                 strokeStyle: new StrokeStyle({color: 0x987654}),
>                 fillStyle: new FillStyle({color: 0x223344, alpha: 0.8}),
>                 radius: 12,
>         tooltip: name,
>                 hasShadow: true
>             }));
>
>         var html:String="<b>"+name+"</b><br/><b>"+address+"</b><br/
>
> >Monday :"+mon+" <br/>Tuesday :"+tue+" <br/>Wednesday :"+wed+" <br/
> >Thurday :"+thur+" <br/>Friday :"+fri+" <br/>Saturday :"+sat+" <br/
> >Sunday :"+sun;
>
>         name : Object = DataBoundMarker(event.target).data;
>
>         ExternalInterface.addCallback("AirportWest", func);
>         function func(value:String) {
>                 //if value == this.name display...
>                 //WHICH MARKER ARE WE USING??
>                 if (value=="AirportWest" ) {
>                         marker[name].openInfoWindow(new
> InfoWindowOptions({contentHTML:html}));
>                 }
>         }
>
>         marker.addEventListener(MapMouseEvent.CLICK,
> function(e:MapMouseEvent):void {;
>         marker.openInfoWindow(new InfoWindowOptions({contentHTML:html}));
>         trace("name "+marker[name]);
>         });
>
>         //trace("marker = >"+ marker);
>         //t.obj(marker, 1, "this is a ", true, " object");
>         //t.str(t.stack);
>
>         //trace("this name="+name);
>
>         return marker;
>
> }
>
> On Feb 23, 12:00 am, RickB <[email protected]> wrote:
>
>
>
> > Hi, Ben.
>
> > I had the same challenge, and after some experimentation, I came up
> > with a very easy and extensible solution which involves extending the
> > Marker class.
>
> > First of all, you can use the event.target to determine which Marker
> > was the source of the event.  Next, you need a way to attach some user
> > data to each Marker.  That's where the magic lies!  See below for an
> > example.  You can follow this pattern to add whatever data you want to
> > a Marker, and then you can access it in the event handler using
> > something like:
>
> > dataForSelectedMarker : Object =DataBoundMarker(event.target).data
>
> > See below for the mechanism for a sample of the extended Marker class.
>
> > HTH,
>
> > Rick
>
> > =============
>
> > package mystuff
> > {
> >   import com.google.maps.overlays.Marker;
> >   import com.google.maps.overlays.MarkerOptions;
> >   import com.google.maps.LatLng;
> >   public classDataBoundMarkerextends Marker
> >   {
> >     [Bindable]
> >     public var data : Object;
> >     public functionDataBoundMarker(arg0:LatLng,
> > arg1:MarkerOptions=null, dataRow:Object=null)
> >     {
> >       super(arg0, arg1);
> >       this.data = dataRow;
> >     }
> >   }
>
> > }
>
> > On Feb 19, 7:45 pm, BenP <[email protected]> wrote:
>
> > > Hi, I have an array of markers, and am looking for a way to identify
> > > which marker the user has just rolled over.
> > > basically getting some kind of Marker ID via the event would be great.
>
> > > I thought abbout adding a custom event, which would contain an
> > > Id:Number field, but i don't know how to extent
> > > MapMouseEvent.ROLL_OVER to insure it will work on a roll over.
>
> > > I can extract the markers latlng form the roll over event, but really
> > > don't want to have to resort to searching my marker array to fine the
> > > correct one.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API For Flash" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api-for-flash?hl=en.

Reply via email to