Reputation: 2500
I need to draw shortest plane path on a map. I created KML in Google Earth and loaded int to Google Map. As you can see attached images: paths is very different: Google Vap path is longer. How to draw arc path on Google map?
Upvotes: 6
Views: 6514
Reputation: 6779
In V3, it's simply adding the geodesic: true
option to your Polyline.
Demo http://jsfiddle.net/yV6xv/20/ Click on the map to define path endpoints
var myLine = new google.maps.Polyline({
map: map,
geodesic: true
});
var path = [];
google.maps.event.addListener(map, 'click', function(event) {
new google.maps.Marker({map:map,position:event.latLng});
path.push(event.latLng);
myLine.setPath(path);
});
Upvotes: 10
Reputation: 9407
This example is for the API V2, but the math is the same for V3: http://maps.forum.nu/gm_flight_path.html
Marcelo.
Upvotes: 0