Flex 网站中的 Google 地图翻转问题

发布于 2024-08-31 22:26:47 字数 3082 浏览 2 评论 0原文

我在 Flex 网站中使用 Google 地图来创建地图。我在地图上覆盖了多边形。当用户将鼠标滑过多边形时,会打开一个信息窗口来标识该区域,并且该区域的填充 Alpha 会设置为 0。展开时,信息窗口会被删除,填充 Alpha 会返回到默认值 0.2。

多边形显示并且信息窗口已正确添加和删除。问题在于填充 Alpha 的更改仅发生在列表中的最后一个多边形上。例如,如果我有多边形 A、B、C 和 D。如果我翻转 A,那么 A 的 alpha 应该改变。但是,D 的 alpha 却发生了变化。无论我翻转哪个多边形,最后一个多边形的 Alpha 都会发生变化。这很奇怪,因为 infoWindows 在翻转时表现正常。因此,如果我将鼠标悬停在多边形 A 上,则会显示 InfoWindow A 的正确信息。

请参阅下面的代码:

private function allEncodedPolygons(event:MouseEvent) : void {
                var myPaneManager:IPaneManager = map.getPaneManager();
                var myMapPane:IPane = myPaneManager.createPane();



                if (allHoodsToggle.selected) { 

                    map.clearOverlays();
                    mapType.selectedIndex = -1;

                    for each (var neighbNode:XML in detailMapResultData){
                      outlinePolygon = this.createPoly(neighbNode);
                    map.addOverlay(outlinePolygon)};

                    allHoodsToggle.removeEventListener(MouseEvent.CLICK, allEncodedPolygons);


                }
               else {myPaneManager.clearOverlays(); allHoodsToggle.removeEventListener(MouseEvent.CLICK, allEncodedPolygons); 

                    }       


    }

下面的函数创建多边形并具有翻转函数:

private var neighbShapes:Polygon;

    private function createPoly(neighbNode:XML):Polygon {
        var optionsDefault:PolygonOptions = new PolygonOptions( { strokeStyle: {thickness: 5, color: 0xFFFF00, alpha: 0.4, pixelHinting: true}, fillStyle: { alpha: 0.2 }} ); 


        var neighbCenterLat:Number = neighbNode.latitudeCenter.toString(); 
        var neighbCenterLong:Number = neighbNode.longitudeCenter.toString(); 
        var neighbCenter:LatLng = new LatLng(neighbCenterLat,neighbCenterLong);
        var optionsHover:PolygonOptions = new PolygonOptions( { fillStyle: { alpha: 0.0 }} ); 
        var encodedData:EncodedPolylineData = new EncodedPolylineData(neighbNode.encoding.toString(), neighbNode.zoomFactor.toString(), neighbNode.level.toString(), neighbNode.numlevels.toString());
        var encodedList:Array = [encodedData];
        neighbShapes = Polygon.fromEncoded(encodedList, optionsDefault);

        neighbShapes.addEventListener(MapMouseEvent.CLICK, function(event:MapMouseEvent): void {
           map.openInfoWindow(event.latLng, new InfoWindowOptions({content: neighbNode.name.toString(), hasCloseButton:false, hasShadow:true}));
        });

        neighbShapes.addEventListener(MapMouseEvent.ROLL_OVER, function(event:MapMouseEvent): void {
            neighbShapes.setOptions(optionsHover);

            map.openInfoWindow(neighbCenter, new InfoWindowOptions({content: neighbNode.name.toString(), hasCloseButton:false, hasShadow:false})); 
        });

        neighbShapes.addEventListener(MapMouseEvent.ROLL_OUT, function(event:MapMouseEvent): void {
            neighbShapes.setOptions(optionsDefault); 
        });

         return neighbShapes;
    }

对于为什么更改 alpha 的函数仅在最后一个多边形上触发,即使 InfoWindow 显示正确,有什么建议吗?如果有人有任何想法,我很想听听。

谢谢。

-拉克斯米迪

I'm using Google Maps in my Flex site to create a map. I've got polygons overlayed on the map. When the user rolls over a polygon an infowindow opens identifying the area and the fill Alpha of the area is set to 0. On roll-out, the info window is removed and the fill Alpha is returned to the default, 0.2.

The polygons display and the InfoWindow is added and removed correctly. The problem is that the change in fill alpha only occurs on the very last polygon in the list. So for example, if I have polygons A, B, C, and D. If I rollover A, then A's alpha should change. But, instead D's alpha changes. No matter which polygon I rollover, the last polygon's alpha changes. It's weird, because the infoWindows behave correctly on rollover. So, if I rollover polygon A, the correct information for InfoWindow A appears.

Please see the code below:

private function allEncodedPolygons(event:MouseEvent) : void {
                var myPaneManager:IPaneManager = map.getPaneManager();
                var myMapPane:IPane = myPaneManager.createPane();



                if (allHoodsToggle.selected) { 

                    map.clearOverlays();
                    mapType.selectedIndex = -1;

                    for each (var neighbNode:XML in detailMapResultData){
                      outlinePolygon = this.createPoly(neighbNode);
                    map.addOverlay(outlinePolygon)};

                    allHoodsToggle.removeEventListener(MouseEvent.CLICK, allEncodedPolygons);


                }
               else {myPaneManager.clearOverlays(); allHoodsToggle.removeEventListener(MouseEvent.CLICK, allEncodedPolygons); 

                    }       


    }

The function below creates the polygons and has the rollover function:

private var neighbShapes:Polygon;

    private function createPoly(neighbNode:XML):Polygon {
        var optionsDefault:PolygonOptions = new PolygonOptions( { strokeStyle: {thickness: 5, color: 0xFFFF00, alpha: 0.4, pixelHinting: true}, fillStyle: { alpha: 0.2 }} ); 


        var neighbCenterLat:Number = neighbNode.latitudeCenter.toString(); 
        var neighbCenterLong:Number = neighbNode.longitudeCenter.toString(); 
        var neighbCenter:LatLng = new LatLng(neighbCenterLat,neighbCenterLong);
        var optionsHover:PolygonOptions = new PolygonOptions( { fillStyle: { alpha: 0.0 }} ); 
        var encodedData:EncodedPolylineData = new EncodedPolylineData(neighbNode.encoding.toString(), neighbNode.zoomFactor.toString(), neighbNode.level.toString(), neighbNode.numlevels.toString());
        var encodedList:Array = [encodedData];
        neighbShapes = Polygon.fromEncoded(encodedList, optionsDefault);

        neighbShapes.addEventListener(MapMouseEvent.CLICK, function(event:MapMouseEvent): void {
           map.openInfoWindow(event.latLng, new InfoWindowOptions({content: neighbNode.name.toString(), hasCloseButton:false, hasShadow:true}));
        });

        neighbShapes.addEventListener(MapMouseEvent.ROLL_OVER, function(event:MapMouseEvent): void {
            neighbShapes.setOptions(optionsHover);

            map.openInfoWindow(neighbCenter, new InfoWindowOptions({content: neighbNode.name.toString(), hasCloseButton:false, hasShadow:false})); 
        });

        neighbShapes.addEventListener(MapMouseEvent.ROLL_OUT, function(event:MapMouseEvent): void {
            neighbShapes.setOptions(optionsDefault); 
        });

         return neighbShapes;
    }

Any suggestions as to why the function that changes the alpha is firing on the last polygon only, even though the InfoWindow appears correctly? If anyone has any ideas, I'd love to hear them.

Thanks.

-Laxmidi

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

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

发布评论

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

评论(1

冷…雨湿花 2024-09-07 22:26:47

好吧,我明白了。我不应该以 neighbShapes 为目标来设置悬停选项,而应该使用: event.currentTarget.setOptions(optionsHover);

-拉克斯米迪

Okay, I figured it out. Instead of targetting neighbShapes to set the hover options, I should have used: event.currentTarget.setOptions(optionsHover);

-Laxmidi

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