Got It!

I had to create a new function inside the one I was trying to set the
event listener.

Instead of...

   marker.addEventListener(MapMouseEvent.CLICK, function(e:Event):void
{
              marker.openInfoWindow(options);
   });

   map.addOverlay(marker);


I just put one line,

        createMarker(marker, options);

and create a new function below called createMarker(marker, options).

Like this:-


private function createMarker(m:Marker, o:InfoWindowOptions):void
                        {
                                m.addEventListener(MapMouseEvent.CLICK, 
function(e:Event):void {
                                m.openInfoWindow(o);
                        });

                         map.addOverlay(m);
                        }


Hope that solves your problem bud, its certainly saved me a lot of
hassle.

Cheers

On Jan 19, 9:39 pm, Rosco <[email protected]> wrote:
> Hi,
>
> This is the exact same problem I am having with my flex app. I have a
> database with marker names, lat and lng. This is all in an
> ArrayCollection though like this:-
>
>    var list:ArrayCollection = e.result.map.loc;
>    for(var i:int=0; i<list.length; i++)
>
> I pretty much do the same as your code where you set up the marker and
> the infowindow options. The only thing different is the
> ArrayCollection but it doesn't seem to make a difference.
>
> So far when a marker is clicked it opens the infowindow but on the
> latest marker added. So its like its only adding the event listener to
> the last thing in the array or every markers infowindow is linked to
> the last marker in the array.
>
> If anyone could help us out it would be greatly appreciated, thanks.
>
> On Jan 19, 7:39 pm, Rob Snow <[email protected]> wrote:
>
> > ok, new question, how do i get each marker to have it's own info
> > window? right now what's happening is that when you click on any
> > marker, it opens an infoWindow (my custom one) in the same spot each
> > time when it should be opening a new one on top of the marker.
> > thanks again
>
> > for each(var place:Place in array){
> >         var latlng:LatLng = new LatLng(place.lat,place.long);
> >         var marker:Marker = new Marker(latlng);
> >         var options:MarkerOptions = new MarkerOptions({label:"S", tooltip:
> > place.description});
> >         marker.setOptions(options);
> >         var infoSprite:InfoWindowSprite = new InfoWindowSprite();
> >         var optionsInfo:InfoWindowOptions = new InfoWindowOptions({
> >                  customContent: infoSprite,
> >                  customOffset: new Point(0, 10),
> >                  customCloseRect: new Rectangle(50, -115, 20, 20)
> >         });
>
> >         marker.addEventListener(MapMouseEvent.CLICK, function
> > (event:Event):void {
> >                 marker.openInfoWindow(optionsInfo);
> >                 });
> >         map.addOverlay(marker);
>
> > }
>
> > On Jan 15, 6:29 pm, Daniel <[email protected]> wrote:
>
> > > Not knowing how you set up your custom info window. I would assume you 
> > > have
> > > a vector graphic for the background of the info window like the example
> > > here:http://gmaps-samples-flash.googlecode.com/svn/trunk/demos/CustomInfoW...
>
> > > All you would do to adjust the window size is change the dimensions of the
> > > rounded rectangle:
>
> > > graphics.drawRoundRect(-75, -110, 160, 100, 10, 10)
>
> > > Danielwww.swfsemantics.com
>
> > > On Thu, Jan 14, 2010 at 1:06 PM, Rob Snow <[email protected]> wrote:
> > > > hmmm... what did you do to specify the height and width so that
> > > > everything fit? I see width, but near as i can tell it's not doing
> > > > anything. I've tried entering it as a number, a string, and a string
> > > > cast as an object. is there a way to tell it to fit contents?
>
> > > > On Jan 14, 7:47 am, Joe <[email protected]> wrote:
> > > > > hi Rob,
>
> > > > > I recently needed to have an infowindow display a title, description
> > > > > and pic as well. You can see an example on this campus maphttp://
> > > > campusmaps.tufts.edu/medford/(not<http://campusmaps.tufts.edu/medford/%28not>all
> > > >  have pics)
>
> > > > > I used the 'customContent' property of the infoWindowOptions -- which
> > > > > takes a DisplayObjecthttp://
> > > > code.google.com/apis/maps/documentation/flash/reference.html#I...
>
> > > > > If you run into anything, post a link (with view source option
> > > > > enabled). It makes it easier to troubleshoot.
>
> > > > > -Joe
>
> > > > > On Jan 12, 5:49 pm, Rob Snow <[email protected]> wrote:
>
> > > > > >http://maps.google.com/search475GayleyAve, Los Angeles, CA 90024
> > > > > > click the marker and it pops up an info window
>
> > > > > > I am using Flex to place items of information and have the markers
> > > > > > laid out on my map. The next step I would like to take would be to
> > > > > > insert an image, write a little information about the piece of
> > > > > > interest and write the title. However, the openInfoWindow only seems
> > > > > > to remember one marker even though I have a for loop attach an on
> > > > > > mouse click to each marker and reference each one's lat and long
> > > > > > Even with this though, there is still a limitation. I can't figure 
> > > > > > out
> > > > > > how to divide up the inforWindow into title, picture, description.
> > > > > > If you are going to link me to
> > > > > >  http://www.marcusschiesser.de/?p=77)
> > > > > > I have already looked at this. It is indeed what I would love to
> > > > > > accomplish, but I cannot for the life of me figure out how to use it
> > > > > > without using his modified google maps api library, which is old and
> > > > > > outdated.
>
> > > > > > private function onMapReady(event:Event):void{
> > > > > >                                 this.map.setCenter(new
> > > > LatLng(34.0093762877589,
> > > > > > -118.49675416946413), 14, MapType.SATELLITE_MAP_TYPE);
> > > > > >                                 map.addControl(new ZoomControl());
> > > > > >                                 map.addControl(new 
> > > > > > PositionControl());
> > > > > >                                 map.addControl(new 
> > > > > > MapTypeControl());
> > > > > >                                 var bool:Boolean =
> > > > this.map.scrollWheelZoomEnabled();
> > > > > >                                 trace(bool.toString());
>
> > > > > >                                 for each(var place:Place in array){
> > > > > >                                         var latlng:LatLng = new
> > > > LatLng(place.lat,place.long);
> > > > > >                                         var marker:Marker = new
> > > > Marker(latlng);
> > > > > >                                         var options:MarkerOptions = 
> > > > > > new
> > > > MarkerOptions({label:"S",
> > > > > > tooltip: place.description});
> > > > > >                                         marker.setOptions(options);
>
> > > > marker.addEventListener(MapMouseEvent.CLICK, function
> > > > > > (event:Event):void {
>
> > > > map.openInfoWindow(latlng, new InfoWindowOptions({title:
> > > > > > place.description, content: "At: " + latlng}));
> > > > > >                                                 });
> > > > > >                                         map.addOverlay(marker);
> > > > > >                                 }
>
> > > > --
> > > > 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]<google-maps-api-for-
> > > >  flash%[email protected]>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/google-maps-api-for-flash?hl=en.
-- 
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