0

是否可以使用 leaflet.js 或 mapbox.js 来确定标记所在的地形/地图类型。例如海洋、陆地、道路或建筑物?

http://leafletjs.com/ http://mapbox.com/

4

2 回答 2

2

如果您正在使用TileMill构建自己的地图,则可以通过交互性来执行此操作:http: //mapbox.com/tilemill/docs/crashcourse/tooltips/您不必出现弹出窗口,而是可以使用 UTFGrid作为键/值存储来指示在地图上点击的区域。

于 2013-05-06T18:03:29.300 回答
0

这不是 LeafletJS 包中提供的方法(据我所知)。

但是,您可以将 Leaflet 地图与Google Geocoding API结合起来以返回location_type,这将告诉您您已经结束了哪种类型的地形特征。

它并不完美,但应该可以为您提供所需的详细程度。

$.getJSON('http://maps.googleapis.com/maps/api/geocode/json?latlng=' + marker._latlng.lat + ',' + marker._latlng.lng + '&sensor=false', function(data) {

  var terrain = data.results[0].geometry.location_type;

});

这是一个jsFiddle展示了它是如何工作的。

于 2013-07-31T06:29:38.163 回答