I am trying to draw a geodesic polyline with Google Maps JavaScript API from two address points.
var polyOptions = {geodesic:true};
var polyline = new GPolyline([
new GLatLng(),
new GLatLng()
], "#f36c25", 5, 0.8, polyOptions
);
map.addOverlay(polyline);
if (GBrowserIsCompatible()) {
map.addOverlay(polyline);
}
Could someone tell me how can I dynamically geocode an address into GLatLng coordinates? I am a little confused after reading Google’s API documentation.
You may want to check out the following example. First it tries to geocode
address1. If it succeeds, it tries to geocodeaddress2. If both succeed, it plots the geodesic polyline between the two coordinates, and two markers:Screenshot: