Hi Jash- We now have an official Map flex component in the 1.7 release. It might be better for you to try use that instead of Igor's component.
It looks like you're actually trying to add the same map to multiple tabs - I don't think that will work. I'd think you'd need to create a new map for every tab. You could also consider using the Static Maps API, if interactivity isn't needed. - pamela On Wed, Oct 1, 2008 at 6:05 AM, Jash <[EMAIL PROTECTED]> wrote: > > Hi > > Just was experimenting with few things. Wanted to open a Google map > with markers every time user clicks on a particular link. I used the > Google map component > http://www.igorcosta.org/?p=140. > > Component : > > package com.mapexample > > { > > import com.google.maps.LatLng; > > import com.google.maps.Map; > > import com.google.maps.MapEvent; > > import com.google.maps.controls.MapTypeControl; > > import com.google.maps.controls.PositionControl; > > import com.google.maps.controls.ZoomControl; > > > > import flash.events.Event; > > import flash.geom.Point; > > > > import mx.core.UIComponent; > > import mx.events.FlexEvent; > > > > public class GoogleFlexMap extends UIComponent > > { > > > > private var _Width:Number = 800; > > private var _Height:Number = 500; > > private var _map:Map; > > //private var _tipomapa:String; > > private var _key:String; > > private var _ZoomControl:Boolean = false; > > private var _PositionControl:Boolean = false; > > private var _TypeControl:Boolean = false; > > > > public function GoogleFlexMap() > > { > > super(); > > super.addEventListener(FlexEvent.INITIALIZE,init); > > > > } > > private function init(event:Event):void { > > this.width = _Width; > > this.height = _Height; > > // Iniciando o Objeto Map > > _map = new Map(); > > try{ > > _map.key =_key; > > } > > catch(e:Error){ > > throw new Error("Please specify a Google Map Key to > start use it!"); > > } > > > > _map.addEventListener(MapEvent.MAP_READY,createUIMap); > > //_map.setSize( new Point (this.width, this.height)); > > if(_ZoomControl){ > > _map.addControl( new ZoomControl()); > > } > > if(_TypeControl){ > > _map.addControl(new PositionControl()); > > } > > if(_TypeControl){ > > _map.addControl(new MapTypeControl()); > > } > > > > // add map Object to UIComponent; > > this.addChild(_map); > > } > > > > public function get showZoomControl():Boolean{ > > return _ZoomControl; > > } > > public function set showZoomControl(value:Boolean):void { > > _ZoomControl = value; > > } > > public function get showPositionControl():Boolean{ > > return _PositionControl; > > } > > public function set showPositionControl(value:Boolean):void { > > _PositionControl = value; > > } > > public function get showTypeControl():Boolean { > > return _TypeControl; > > } > > public function set showTypeControl(value:Boolean):void { > > _TypeControl = value; > > > > } > > public function get key():String{ > > return _key; > > } > > public function set key(value:String):void { > > _key = value; > > } > > > > private function createUIMap(event:Event):void { > > _map.setCenter( new LatLng(40.736072,-73.992062),14,null); > createMarker(new LatLng(40.736072,-73.992062)); > > } > > private function createMarker(markerLatLng:LatLng):void{ > var marker:Marker = new Marker(markerLatLng); > _map.addOverlay(marker); > } > > > > override protected function > updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{ > > super.updateDisplayList(unscaledWidth, unscaledHeight); > > _map.setSize( new Point(unscaledWidth,unscaledHeight)); > > } > > } > > } > > Have just added another method in above code which plots a marker > after setting center. > Usual create marker method. > > Then called the above component using MXML canvas component like below > which is MapView.mxml > > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" > xmlns:gmap="com.mapexample.*" width="100%" height="100%" label="Map" >> > <gmap:GMapFlex id="gMap" zoomControl="true" > positionControl="true" typeControl="true" > mapKey="ABQIAAAA5h13hQY5zPl5KVebQmWUnxTwM0brOpm- > All5BF6PoaKBxRWWERT3bhIvogMkD929TarmSs0hY8ILKQ" > zoomLevel="6" width="100%" height="100%" /> > </mx:Canvas> > > > Then tried callin it to open in new tab like below > > private var i:Number = 1 ; > > private function addTab():void{ > > private static var map:MapView = new MapView(); > Mainscreen.tabNav.addChild(map); > Mainscreen.tabNav.label = "MapTab" + i ; > MainScreen.tabNav.selectedChild = map; > i++; > } > > When i try doing this i get Runtime error , at _map.addoverlay where > it tries adding the marker. > Can anybody try using this component and plotting multiple markers on > map and open it in different tabs... I want to know what is the > problem , why is it failing to add markers in multiple tabs. > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
