w-rong

<div id="container"></div>
 
var map = new AMap.Map("my_container", {
        resizeEnable: true,
        center: [120.946263, 30.526436],
        zoom: 10
      });//初始化地图
      var district = null;
      var opts = {
        subdistrict: 0, //获取边界不需要返回下级行政区
        extensions: "all", //返回行政区边界坐标组等具体信息
        level: "district" //查询行政级别为 市
      };
      district = new AMap.DistrictSearch(opts);
      district.search("xx县", function(status, result) {
        var polygons = [];
        var bounds = result.districtList[0].boundaries;
        if (bounds) {
          for (var i = 0, l = bounds.length; i < l; i++) {
            //生成行政区划polygon
            var polygon = new AMap.Polygon({
              strokeWeight: 1,
              path: bounds[i],
              fillOpacity: 0.1,
              fillColor: "#80d8ff",
              strokeColor: "#2084DC",
              strokeStyle: "dashed",
              strokeWeight: 2
            });
            polygons.push(polygon);
          }
        }
        map.add(polygons);
        map.setFitView(polygons); //视口自适应
      });

分类:

技术点:

相关文章:

  • 2021-12-20
  • 2021-07-05
  • 2021-06-04
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
相关资源
相似解决方案