高德行政区 涟漪 范围

发布于 2020-10-28  63 次阅读


     this.CompanyInfoList.forEach(element => {

        markers.push(
          new AMap.Marker({
            position: [element.addressLongitude, element.addressLatitude],
            offset: new AMap.Pixel(-13, -30),
            content: content,
            extData: element.sliceId
          })
        )
      })
      let count = markers.length

      let _renderClusterMarker = function (context) {
        var factor = Math.pow(context.count / count, 1 / 18)
        var div = document.createElement('div')
        var Hue = 180 - factor * 180
        var bgColor = 'hsla(' + Hue + ',100%,50%,0.7)'
        var fontColor = 'hsla(' + Hue + ',100%,20%,1)'
        var borderColor = 'hsla(' + Hue + ',100%,40%,1)'
        var shadowColor = 'hsla(' + Hue + ',100%,50%,1)'
        div.style.backgroundColor = bgColor
        var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20)
        div.style.width = div.style.height = size + 'px'
        div.style.border = 'solid 1px ' + borderColor
        div.style.borderRadius = size / 2 + 'px'
        div.style.boxShadow = '0 0 1px ' + shadowColor
        div.innerHTML = context.count
        div.style.lineHeight = size + 'px'
        div.style.color = fontColor
        div.style.fontSize = '14px'
        div.style.textAlign = 'center'
        context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2))
        context.marker.setContent(div)
      }
      addCluster(2)
      function addCluster(tag) {
        if (tag == 2) {
          //完全自定义
          new AMap.MarkerClusterer(map, markers, {
            gridSize: 80,
            renderClusterMarker: _renderClusterMarker
          })
        }
      }
      


function addPary(json) {
        let regionList = []
        json.map(item => {
          regionList.push(new AMap.LngLat(item.longitude, item.latitude))
        })
        //生成行政区划polygon
        var polygon = new AMap.Polygon({
          strokeWeight: 1,
          path: regionList,
          fillOpacity: 0.4,
          fillColor: '#80d8ff',
          strokeColor: '#0091ea'
        })
        // polygons.push(polygon)

        map.add(polygon)
        // map.setFitView(polygons) //视口自适应
      }

Lifelong learning lifelong benefit