最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

leaflet - How to get elevation from current latitude and longitude using leafltejs OR mapbox javascript API - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 4

Leaflet 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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论