I have two coordinates for which I would like to draw a perpendicular line of equal length. Is there either a simple google map mapping for this, or a clean JavaScript approach with which I could do this? What will it be?
Here is what I still have. As you can see, I draw two points as markers, and then try to draw a line between them, except that I need to move this straight line between the two coordinates.
var locations = [ ['', position.coords.latitude, position.coords.longitude, 1], ['', llat, llng, 2] ]; var marker, i; for ( var i = 0; i < locations.length; i++ ) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][1], locations[i][2]), map: map }); } var borderPlanCoordinates = [ new google.maps.LatLng(llat, position.coords.longitude), new google.maps.LatLng(position.coords.latitude,llng) ]; var borderPath = new google.maps.Polyline({ path: borderPlanCoordinates, strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 10, map: map }); borderPath.setMap(map);
source share