Hi bbb,
Yeah Pamela's right, but geocoding sounded scary to me at first, no
need to fear it's actually not bad.
you just do this (btw I know you just need an address not a route this
should still work I think)
import com.google.maps.services.Directions;
import com.google.maps.services.DirectionsEvent;
private function someMethod(somePlace:String="1234 Main St. Chicago
IL"):void{ /*This actually plots to somewhere in Evanston to give you
an idea of how flexible it can be*/
var dir:Directions = new Directions();
dir.addEventListener(DirectionsEvent.DIRECTIONS_SUCCESS,
onDirLoad);
dir.addEventListener(DirectionsEvent.DIRECTIONS_FAILURE,
onDirFail);
dir.load(somePlace);
}
to fetch some directions then in the handler (and make a fault handler
if you want to deal with it not being able to resolve the address)
private function onDirLoad(event:DirectionsEvent):void {
var dir:Directions = event.directions;
theMap.addOverlay(dir.createPolyline());
/* the line above just plots the entire route, the directions object
that comes back in the event, potentially has multiple routes (or
maybe just 1 if it's just 1 location you're looking up or 2 locations
since a route would be between the two locations, so lets say it's
just an address then you want to get the geoloc of that one location
it should be something along these lines*/
var theLatLng:LatLng=new LatLng(dir.getRoute
(0).startGeocode.point.lat(), dir.getRoute(0).startGeocode.point.lng
());
var marker:Marker = new Marker(theLatLng);
}
you'll probably have to play around with that some to figure out the
exact parts you need but that's the general idea, so you ask the
geocoder to give you back info but it's asynchronous meaning it's not
going to hold up you're app while it's fetching the data (which may or
may not be what you want, but that's how it goes) then it will call
back to your handler, once it figures it out. From what I've seen the
Google geocoder is super flexible in the strings it will parse, so you
can just say something like "1234 Main St. Chicago IL" and it'll
figure out the parts or "Chicago, IL to San Diego, CA" my guess is you
can just keep chaining them along with "to" in between different
"routes" but I really haven't played with it that much, doesn't seem
like it'd be an issue for your case anyhow.
Good luck,
Shaun
On Oct 14, 9:48 am, bbb <[email protected]> wrote:
> Hi,
>
> I have a question, is it possible to insert a marker using a street
> address instead of LatLng?
>
> var marker:Marker = new Marker(new LatLng(lat, lon));
>
> Thank you.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---