Beautiful, thanks! We're working on a new geocoding response format that's not quite so nasty to parse. (You can see it in the JS API v3 documentation if you're curious).
- pamela On Wed, Jun 3, 2009 at 2:46 PM, Aaron Donohue <[email protected]> wrote: > > Thanks for adding the extended data. It works beautifully now. I > initially had some confusion as to which values (N, E, S, W) were the > lat and which values were the lon, but once I figured it out things > fell into place. To save others some time here is what the code would > look like. > > private function doGeocode(event:Event):void { > // Geocoding example > var geocoder:ClientGeocoder = new ClientGeocoder("AU"); > geocoder.addEventListener( > GeocodingEvent.GEOCODING_SUCCESS, > function(event:GeocodingEvent):void { > output.text = ObjectUtil.toString(event.response); > var placemarks:Array = event.response.placemarks; > if (placemarks.length > 0) { > var placemark:Object = placemarks[0]; > var viewport:LatLngBounds = new LatLngBounds( > new LatLng(placemarks[0].ExtendedData.LatLonBox.south, > placemarks > [0].ExtendedData.LatLonBox.west), > new LatLng(placemarks[0].ExtendedData.LatLonBox.north, > placemarks > [0].ExtendedData.LatLonBox.east)); > map.setCenter(placemark.point, map.getBoundsZoomLevel > (viewport)); > createMarker(placemark.point); > } > }); > geocoder.addEventListener( > GeocodingEvent.GEOCODING_FAILURE, > function(event:GeocodingEvent):void { > Alert.show("Geocoding failed"); > }); > geocoder.geocode(address.text); > } > > > > On Jun 3, 8:47 am, pamela fox <[email protected]> wrote: >> Hi Aaron- >> >> We now supply the suggested viewport in the geocoding response. You >> can see what it looks like >> here:http://gmaps-samples-flash.googlecode.com/svn/trunk/demos/GeocodingDe... >> It's in ExtendedData -> LatLonBox - > east/west/north/south >> >> You can create a LatLngBounds out of that, and then center using >> map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); >> >> - pamela >> >> On Fri, May 29, 2009 at 3:54 PM, Aaron Donohue <[email protected]> >> wrote: >> >> > I am attempting to implement search capability on a google map similar >> > to the GeocodeSimple example ( >> >http://gmaps-samples-flash.googlecode.com/svn/trunk/examples/Geocodin... >> > ). I would like to implement a smart way to zoom and am falling short >> > on how to solve the problem. My thought is that when the user enters >> > "colorado" as the destination to search for...that it would zoom to a >> > reasonable state zoom level (like 7), if I searched for "denver, co" >> > it would zoom to a city zoom level (like 11), or if I searched for an >> > address that it would zoom to a street zoom level (like 16, 17) much >> > like how maps.google.com behaves. My thought is that I am missing >> > something that may already exist and I can't find, like a geocode >> > method that returns bounds that I could zoom to or a geocode method >> > that provides the appropriate zoom level for the user specified search >> > criteria. How can I achieve this? > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
