views:

20

answers:

1

Hi,

I'm trying to create a Google Map with Flex 3 to dispaly the location of schools. When the user rolls over the school marker, the InfoWindow is supposed to show the name of the school.

The markers are working fine. Unfortunately, the name of the school is not showing in the InfoWndow. I think that I have a problem in the InfoWindowOptions.

Please see the function below:

public function schoolMarkerBuilder():void {

    var schoolArrayLength:uint = schoolPointsData.length;
    var i:int;

    for  (i=0; i < schoolArrayLength; i++) {

    schoolMarkers = new Marker(new LatLng(schoolPointsData[i].latitude, schoolPointsData[i].longitude),
        new MarkerOptions({
        strokeStyle: new StrokeStyle({color: 0x000000}),
        fillStyle: new FillStyle({color: 0x223344, alpha: 0.8}),
            radius: 12,
            hasShadow: true
                   })

        );

         schoolMarkers.addEventListener(MapMouseEvent.ROLL_OVER, function(event:MapMouseEvent): void {
           map.openInfoWindow(event.latLng, new InfoWindowOptions({content:schoolPointsData[i].school_name, hasCloseButton:false, hasShadow:true}));
        });

         map.addOverlay(schoolMarkers);

                 }


        }

Any suggestions?

Thank you.

-Laxmidi

A: 

Hi,

Okay, I figured it out. Please see the code below:

public function schoolMarkerBuilder():void {

        var schoolArrayLength:uint = schoolPointsData.length;
        var i:int;

        for  (i=0; i < schoolArrayLength; i++) {

        var options:InfoWindowOptions = new InfoWindowOptions({content: schoolPointsData[i].school_name});
        schoolMarkers = new Marker(new LatLng(schoolPointsData[i].latitude, schoolPointsData[i].longitude),
        new MarkerOptions({
            strokeStyle: new StrokeStyle({color: 0x000000}),
            fillStyle: new FillStyle({color: 0x223344, alpha: 0.8}),
            radius: 12,
            hasShadow: true
                })

                    );


            createMarker(schoolMarkers, options);

                 }


        }   


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

            map.addOverlay(m);
        }

Thank you.

-Laxmidi

Laxmidi