javascript - 根据地理位置检测区域

标签 javascript google-maps google-maps-api-3 location geo

我有一个包含区域列表的 json 文件。

每个区域都有地理边界点,例如:

id": "4650d7cc-b834-4ed4-a139-40f5037711fc",
"name": "region 1",
"coords": [
    [
        [4.74, 52.431],
        [4.781, 52.426],
        [4.831, 52.42],
        [4.855, 52.417],
        [4.862, 52.422],
        [4.861, 52.425],
        [4.866, 52.428], ...

如何使用 js、C# 或任何 Google 服务根据某个位置检测区域?

最佳答案

您可以使用 Google Maps JavaScript API Geometry Library 中的 containsLocation 方法。来自 the documentation :

containsLocation(point:LatLng, polygon:Polygon)

Return Value: boolean

Computes whether the given point lies inside the specified polygon.

关于javascript - 根据地理位置检测区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39659964/

相关文章:

python - 从 Google Map Mobile 3.0 的 MyLocation 功能中检索纬度/经度

ios - 在 iOS 中移动 GMSPolyline

java - 如何知道 map 中某个位置何时位于另一个位置的前面/后面

google-maps - 如何使用 Google Places API 搜索特定类型的地点?

javascript - 谷歌地图信息窗口中的 Symfony 动态通配符

javascript - 使用浏览器密码记住功能的 Ajax 登录表单

javascript - 数据表滚动

java - 如何在 Android 中的 Google map 上显示 Circle 的信息窗口

api - 如何为谷歌地图制作热图叠加层(如 Trulia crime)

javascript - 如何从 branch.io 的身份访问 Branch Identity ID