I am working with leafletjs and added MAP. I want to get elevation from current latitude and longitude or current place only, but it will return whole path elevation.
var el = L.control.elevation();
el.addTo(map);
var gjl = L.geoJson(geojson,{
onEachFeature: el.addData.bind(el)
}).addTo(map);
map.addLayer(service).fitBounds(bounds);
How can I find the elevation with either mapbox or leafletjs.
I am working with leafletjs. and added MAP. I want to get elevation from current latitude and longitude or current place only, but it will return whole path elevation.
var el = L.control.elevation();
el.addTo(map);
var gjl = L.geoJson(geojson,{
onEachFeature: el.addData.bind(el)
}).addTo(map);
map.addLayer(service).fitBounds(bounds);
How can I find the elevation with either mapbox or leafletjs.
Share Improve this question edited Dec 6, 2017 at 0:45 Steve Bennett 127k45 gold badges186 silver badges244 bronze badges asked Dec 5, 2017 at 8:52 VedVed 2,7012 gold badges24 silver badges30 bronze badges 3- What do you mean with current place only and current latitude and longitude? Looking at your code it seems that you are adding elevation to every feature element – kiks73 Commented Dec 5, 2017 at 8:57
- elevation of current place only, above code return elevation of whole json data. – Ved Commented Dec 5, 2017 at 8:59
- I want like this developers.google./maps/documentation/javascript/examples/… – Ved Commented Dec 5, 2017 at 9:01
2 Answers
Reset to default 4Leaflet is a map display library, not a data API, not a elevation raster query library.
For this, you will have to rely in some kind of elevation dataset (which one is "better" depends on your definition of "better").
For example, see Getting Altitude(height from sea level) of my location in iphone SDK
Whether to use a service like that or whether you should have your own elevation dataset is up to you. In any case, Leaflet does not provide a favourite elevation query service by default (contrary to what Google Maps does, as it relies on Google's elevation datasets).
Extending on @IvanSanchez's answer, you'll need to integrate a service to grab the elevation from your point. One such library which will do this with Mapbox is https://github./mcwhittemore/mapbox-elevation