传单将坐标转换为街道地址

时间:2018-08-06 07:18:24

标签: javascript angular typescript leaflet maps

我正在创建一个使用传单地图的应用程序。我想知道是否可以使用任何外部库将坐标转换为街道地址?我正在使用Angular 6。

2 个答案:

答案 0 :(得分:3)

使用命题在这里是一种非常简单的可能性。这是OpenStreetmap使用的工具。这是所有详细信息的链接: https://wiki.openstreetmap.org/wiki/Nominatim

这是有关如何使用它的示例:

$.get('https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=47.217954&lon=-1.552918', function(data){
    console.log(data.address.road);
});

您只需要用这样的变量替换坐标:

lat='+ latitude +'

如果需要插件:https://esri.github.io/esri-leaflet/examples/reverse-geocoding.html

答案 1 :(得分:3)

您要的内容称为Geocoding。对于Leaflet,有很多插件可以完成此操作,所有插件均在https://leafletjs.com/plugins#geocoding中列出。请注意,某些插件(例如https://github.com/perliedman/leaflet-control-geocoder)不仅限于一个地理编码提供程序。

相关问题