I am very new to this and looks very interesting to me. Is there a way to create route between pointA and pointB based on elevation restriction. I am trying to use this for planes so doesn't need to follow any roads :)
IE: Elevation limit: 200 meters
pointA: 38°44′50″N , 090°21′41″W - Saint Louis Airport
pointB: 39°02′56″N , 084°40′04″W - Cincinnati Airport
How can I draw a route from pointA to pointB without exceeding elevation limit?
Thanks in advance...
$(document).ready(function() {
var path = [
{lat: 38.74722222, lng: -90.36138889}, // St Louis
{lat: 39.04888889, lng: -84.66777778}]; // Cincinnati
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 6,
maxZoom: 8,
minZoom: 1,
streetViewControl: false,
center: path[1],
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var flightPath = new google.maps.Polyline({
path: path,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
});
html,
body,
#map {
height: 100%;
width: 100%;
padding: 0px;
margin: 0px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map"></div>
By now it is not possible to let Google Maps calculate a route that does not exceed a specfied elevation limit.
This applies to both:
What is available by now is to request elevation data for specified locations and in addition elevation data alongside this specified locations in a given resolution (eg when 2 locations are specified then
samples=3
will result in elevation data for the two endpoints and the halfway point).So theoretically it is possible to
This might be an expensive task depending on the elevation limit itself and the distance as well.
Reference: https://developers.google.com/maps/documentation/elevation/intro
Footnote / Hint
I would suggest to have a look at other APIs (eg OpenStreetMap). Maybe there is an API that provides the calculation of a route based on elevation.
If Google Maps UI is wanted on frontend the retrieved route might be transferred to Google Maps (which would be the easiest part).