mapquestelevation

Fetching elevation of one point from MapQuest API in Leaflet


I am trying to get elevation of clicked location via fetching elevation values from MapQuest elevation profile API

https://developer.mapquest.com/documentation/open/elevation-api/elevation-profile/get/

But I can't find the parameter of getting elevation of only one point not for a route; I mean latLng not latLngCollection.

Here is my code:

var myLocation = e.latlng;
  console.log(myLocation);
  fetch('http://open.mapquestapi.com/elevation/v1/profile?key=tHXSNAGXRx6LAoBNdgjjLycOhGqJalg7&shapeFormat=raw&latLngCollection='+myLocation)
  .then(r => r.json()) 
    .then(data => {
      var elevation = data;
      console.log(data);
})

Is there is any way to get elevation for only one point?


Solution

  • A one location collection seems to be working as expected.

    http://open.mapquestapi.com/elevation/v1/profile?shapeFormat=raw&key=KEY&latLngCollection=51.50631,%20-0.12714