Flex 3 网站中的 Google 地图 InfoWindow 问题

发布于 2024-09-12 12:15:48 字数 1073 浏览 3 评论 0原文

我正在尝试使用 Flex 3 创建一个 Google 地图来显示学校的位置。当用户将鼠标悬停在学校标记上时,信息窗口应该显示学校的名称。

标记工作正常。不幸的是,学校的名称没有显示在信息窗口中。我认为 InfoWindowOptions 存在问题。

请看下面的功能:

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);

                 }


        }

有什么建议吗?

谢谢。

-拉克斯米迪

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最佳男配角 2024-09-19 12:15:48

好吧,我明白了。请看下面的代码:

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);
        }

谢谢。

-拉克斯米迪

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文