1

我正在尝试使用 flex 移动项目 4.5 的操作脚本在谷歌地图上创建多个标记

这是我经过城市的代码,它将加载谷歌地图

        import spark.events.ViewNavigatorEvent;


        private var myWebView:StageWebView;
        private var city:String;

        /**
         * @protected 
         * Just add and set site of my StageWebView 
         * */

        protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
        {

            // set the city with data default property of each view

            city = data.toString();

             myWebView = new StageWebView();
             myWebView.stage = this.stage;
            // myWebView.loadURL("http://maps.google.com"); // default
             myWebView.loadURL("http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q="+ city + "&z=12&sensor=true");

             myWebView.viewPort = new Rectangle(0,70,stage.stageWidth,stage.stageHeight);
        }


        /** 
         * @private
         *  
         * Just override to re-scale due to auto-orientation project nature
         * */
        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {


            if (myWebView) {
                var point:Point = localToGlobal(new Point());
                myWebView.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
            }
        }   
        override protected function stateChanged(oldState:String, newState:String, recursive:Boolean):void
        {

        }

        protected function goBackHandler(event:MouseEvent):void
        {

            navigator.popToFirstView();

        }

        protected function removeStageWebViewHandler(event:ViewNavigatorEvent):void
        {
            myWebView.stage = null;
            // just remove the target and will leave.

        }


    ]]>
</fx:Script>
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:navigationContent>
    <s:Button label="Go Back" click="goBackHandler(event)"/>
</s:navigationContent>

我想通过将所有城市存储在数组中来传递城市并显示所有城市(标记)受保护的函数 view1_viewActivateHandler(event:ViewNavigatorEvent):void {

        // set the city with data default property of each view

        city = data.toString();

         myWebView = new StageWebView();
         myWebView.stage = this.stage;
        // myWebView.loadURL("http://maps.google.com"); // default
         myWebView.loadURL("http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q="+ city + "&z=12&sensor=true");

         myWebView.viewPort = new Rectangle(0,70,stage.stageWidth,stage.stageHeight);
    }

请帮助

4

1 回答 1

0

利用

myWebView.loadURL("http://maps.googleapis.com/maps/api/staticmap?f=q&source=s_q&hl=en&geocode=&center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Ccolor:red%7Clabel:C%7C40.718217,-73.998284&sensor=false&z=12&sensor=true");

这将在 flex 移动应用页面上创建多个标记

于 2013-02-20T23:16:17.247 回答