高德地图判断坐标点,是否在某一个区县

 AMapLoader.load({
        key: '11111111111',
        version: '2.0',
      })
        .then(AMap => {
          // 初始化地图,
          this.AMapHandler = AMap
          this.map = new AMap.Map('map_container', {
            viewMode: '3D',
            zoom: 15
          })
        })

posDiff( name='江岸区') {
      this.AMapHandler.plugin(['AMap.DistrictSearch'], () => {
     
      // 创建行政区查询对象
        var district = new this.AMapHandler.DistrictSearch({
        // 返回行政区边界坐标等具体信息
          extensions: 'all',
          // 设置查询行政区级别为 区
          level: 'district'
        })

        district.search(name, (status, result) => {
        // 获取泉州市的边界信息
          var bounds = result.districtList[0].boundaries

          this.qh_path = bounds
        })
      })
    },
    compute(point) {
 // 判断点再不是区县范围
      var isPointInRing = this.AMapHandler.GeometryUtil.isPointInRing(point, this.qh_path)
      return isPointInRing
    },

//调用
this.compute([lng, lat])
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容