Are you clicking doSearch() sufficiently after the map's initialization step? Does it make it to either of the event handler callbacks?
- pamela On Thu, Dec 24, 2009 at 1:56 AM, Mark Shen <[email protected]> wrote: > Thanks for Help > > This is my test code.I do not know why it have that error. thanks > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" > backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FDFCFC, > #FDFCFC]" > initialize="startMap()"> > <mx:Script> > <![CDATA[ > import com.google.maps.LatLng; > import mx.controls.Alert; > import com.google.maps.services.GeocodingEvent; > import com.google.maps.services.ClientGeocoder; > > import com.google.maps.Map; > > private var map:Map; > > public function startMap():void { > map = new Map(); > map.key = > "ABQIAAAA7QUChpcnvnmXxsjC7s1fCxQGj0PqsCtxKvarsoS-iqLdqZSKfxTd7Xf-2rEc_PC9o8IsJde80Wnj4g"; > > } > > private function doSearch():void{ > > var geocoder:ClientGeocoder = new ClientGeocoder(); > > geocoder.addEventListener(GeocodingEvent.GEOCODING_SUCCESS,geoHandler); > > geocoder.addEventListener(GeocodingEvent.GEOCODING_FAILURE,failHander); > geocoder.geocode(addressValue.text); > } > > private function geoHandler(event:GeocodingEvent):void{ > > var placemarks:Array = event.response.placemarks; > if (placemarks.length > 0) { > var latLngData:LatLng = placemarks[0].point; > latitudeValue.text = String(latLngData.lat()); > longitudeValue.text = String(latLngData.lng()); > }else{ > > latitudeValue.text = '0'; > longitudeValue.text = '0'; > > } > trace("good"); > } > > private function failHander(event:GeocodingEvent):void{ > > Alert.show("error happens!!!"); > trace("fail"); > } > ]]> > </mx:Script> > <mx:Label x="36" y="62" text="Address" fontWeight="bold"/> > <mx:Label x="36" y="107" text="Detail:" fontWeight="bold"/> > <mx:Label x="36" y="23" text="Search" fontWeight="bold"/> > <mx:Label x="81" y="153" text="Latitude:"/> > <mx:Label x="144" y="153" width="369" id="latitudeValue"/> > <mx:Label x="66" y="187" text="Longitude:"/> > <mx:Label x="144" y="187" width="369" id="longitudeValue"/> > <mx:TextInput x="114" y="60" width="387" id="addressValue" text="200 > Yorkland Blvd Toronto ON Canada"/> > <mx:Button x="36" y="241" label="Search" click="doSearch()"/> > > </mx:Application> > > > > > -- > > 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.
