You need a timer and should move where you are removing your listener.
On Sat, May 21, 2011 at 7:55 AM, Eoghan <[email protected]> wrote: > Hi guys, any idea why my Map object gets drawn like this below? It's > unpannable and unzoomable even if I press my refresh button top right which > calls setCenter again. > > Using the onMapReady function with a setCenter option pulling the latitude > and longitude from a GPS Geolocation event (which is accurate, I popped the > latlng into google maps and got my area) > > Do I have to redraw the Map object somehow on Refresh? > > > <https://lh5.googleusercontent.com/_1UlBh3SUm2k/TdbhhO_uvCI/AAAAAAAAAdA/MURl7q8fV3w/pic.jpg> > > > Code and MXML: > > protected function init():void > { > if (Geolocation.isSupported) > { > if (g.muted) > { > log.text = "Access to GPS has been muted!"; > return; > } > log.text = "Finding Location..."; > g.addEventListener(GeolocationEvent.UPDATE, > onUpdate); > addEventListener(FlexEvent.REMOVING,onRemove); > } > else > { > log.text = "Geolocation is not supported on this > device!"; > } > } > > private function onUpdate(event:GeolocationEvent):void > { > trace("Update event called"); > latitude = event.latitude; > longitude = event.longitude; > var latlng:LatLng = new LatLng(latitude,longitude); > } > > protected function onRemove(event:FlexEvent):void > { > g.removeEventListener(GeolocationEvent.UPDATE, > onUpdate); > } > > private function onMapReady(event:MapEvent):void { > map.addOverlay(new Marker(latlng)); > map.setCenter(latlng, 17, MapType.NORMAL_MAP_TYPE); // > (latlng, zoomlevel, maptype) > } > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > > <maps:Map xmlns:maps="com.google.maps.*" > id="map" left="0" right="0" top="7.15" bottom="119.849976" > key="1234" > mapevent_mapready="onMapReady(event)" sensor="true" > url="http://code.google.com/apis/maps/"/> > > -- > 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. > -- 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.
