【问题标题】:Google maps API v3 : containsLocation() vs. geojson dataGoogle maps API v3: containsLocation() 与 geojson 数据
【发布时间】:2014-11-07 14:48:11
【问题描述】:

我在我的 Web 应用程序中有一个在地理上划分为社区的城市。我使用 geojson 文件描述为以下数组:

 "type": "FeatureCollection",
 "features": [
 {
  "geometry": {
    "type": "Polygon",
    "color" : "red",
    "coordinates": [
      [
        [
          2.38317,
          48.867111
        ],
        [
          2.363713,
          48.867554
        ],
        [
          2.364399,
          48.867126
        ],
        [
          2.39839,
          48.85133
        ],
        [
          2.39432,
          48.856541
        ],
        [
          2.39223,
          48.857571
        ],
        [
          2.38965,
          48.85844
        ],
        [
          2.38746,
          48.86282
        ],
        [
          2.38377,
          48.86607
        ],
        [
          2.38317,
          48.867111
        ]
      ]
    ]
  },
  "properties": {
    "id" : "11",
    "name": "11ème : arr",
    "description": "this is 11",
    "arr": "11e"
  }
}, ...

我的目标是查看用户地址在我的多边形中的位置。我从HTML5 get my location 获取地址,或者通过在自动完成搜索栏中输入自己的地址,它返回 => google.maps.LatLng 对象。

知道 containsLocation 需要 LatLng 格式的多边形,如何探索淹没的多边形对象

Here's the example which uses google.maps.Polygon object

【问题讨论】:

    标签: javascript android google-maps google-maps-api-3


    【解决方案1】:

    我找到了答案,我已经用这个脚本转换了所有功能

    https://github.com/JasonSanford/geojson-google-maps/blob/master/GeoJSON.js

    【讨论】:

      猜你喜欢
      • 2014-08-08
      • 2016-05-28
      • 2017-10-24
      • 1970-01-01
      • 2015-03-04
      • 2014-10-05
      • 1970-01-01
      • 2011-07-19
      • 2021-03-26
      相关资源
      最近更新 更多