Using PhoneGap API ◾ 217
var line = new google.maps.Polyline({
path: [marker1.getPosition(), marker2.getPosition()],
strokeColor: '#FF0000',
strokeOpacity: 1.0,
map: map
});
Note: e map property is essential in Polyline and other drawing classes because it defines the
map object on which the line has to be drawn.
Finding the Distance between Two Positions
To find out the distance between two position objects, the computeDistanceBetween()
method is used, as shown in the statements below:
var p1 = new google.maps.LatLng(latitude_value1, longitude_value1);
var p2 = new google.maps.LatLng(latitude_value2, longitude_value2);
d = google.maps.geometry.spherical.computeDistanceBetween(p1, p2);
We can see that positions, that is, LatLng instances, p1 and