If you created a Directions query for a very small route from the
point you're interested in to a point very close to that point then
the resulting line will be snapped to the closest road.
Something like:
var directions : Directions = new Directions();
var pt1 : LatLng = marker.getLatLng();
var pt1 : LatLng = new LatLng(pt1.lat() + 0.000001, pt1.lng());
directions.addEventListener(DirectionsEvent.DIRECTIONS_SUCCESS,
function (e:DirectionsEvent)
{
var dir_poly : IPolyline
= e.directions.createPolyline();
var road_pt: LatLng =
null;
if
(dir_poly.getVertexCount() > 0) {
road_pt =
dir_poly.getVertex(0);
}
// road_pt is now the
closest road to the marker, snap the marker to the road
marker.setLatLng
(road_pt);
});
directions.load("from: " + pt1.toString() + " to: " + pt2.toString());
should snap the marker to the closest road.
Cheers,
Chris
On Aug 28, 11:53 pm, James Sun <[email protected]> wrote:
> Is it possible to figure out if a marker is over or on top of a road
> using the Google Maps API for Flash? I'd like to restrict users to
> placing markers on roads.
>
> Thanks,
> James
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---