单张latlng到位置的名称 [英] leaflet latlng to name of location

查看:93
本文介绍了单张latlng到位置的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个表单,默认情况下该位置将被传递给一个输入元素。 (基本上,点击地图并在表单上默认坐标)
虽然我需要使用坐标系,并且我没有任何问题返回坐标,但我想显示城市/区域的名称

I'm creating a form where the location is being passed to an input element by default. (Basically, click on the map and the coords are default on the form) While I need to work with the coords, and I have no problem returning the coordinates, I want to show the name of the city/area of those coords in the form instead of the lat/lng.

<input type="text" id="coords_lat" name="loc_lat" value={{clickedLat}} disabled>
<input type="text" id="coords_lng" name="loc_lng" value={{clickedLng}} disabled>

现在我正在展示这样的内容,但我想展示一些简单的内容,例如Madrid,西班牙,甚至可以得到这些协议的实际地址。
这可能与Leaflet有关吗?

Right now I'm showing like this, but I would like to show something simple like "Madrid, Spain" or even get the actual address of those coords. Is this possible to do with Leaflet?

(注意我在这个项目中使用meteorjs)

(note i'm using meteorjs in this project)

推荐答案

您所描述的功能称为 反向地理编码

The functionality you describe is called reverse geocoding.

您需要外部服务才能执行此类操作(例如,您需要使用外部Tile Server来获取栅格图块)。

You need an external service to perform such operation (like you need an external Tile Server to get raster tiles).

您可以使用传单控制地理编码器插件,它抽象了一些对外部(反向)地理编码服务的调用:

You can use Leaflet Control Geocoder plugin, which abstracts some of the calls to external (reverse) geocoding services:


一个简单的Leaflet地理编码器,默认情况下使用OSM / Nominatim 。

A simple geocoder for Leaflet that by default uses OSM/Nominatim.

这篇关于单张latlng到位置的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆