Skip to content

在生产环境中聚合图层和添加到聚合图层中的所有marker同时显示出来, 在开发环境中又是正常的 #63

@Curreter

Description

@Curreter

在生产环境中聚合图层和添加到聚合图层中的所有marker同时显示出来, 在开发环境中又是正常的,
初始化聚合图层的代码:

  new ClusterLayer('cluster', [], {
          zIndex: 100,
          noClusterWithOneMarker: false,
          noClusterWithHowMany: 8, //聚合的最小个数
          maxClusterZoom: 15,
          //"count" is an internal variable: marker count in the cluster.
          symbol: {
            markerType: 'ellipse',
            markerFill: {
              property: 'count',
              type: 'interval',
              stops: [
                [0, 'rgb(135, 196, 240)'],
                [9, '#1bbc9b'],
                [50, 'rgb(116, 115, 149)'],
                [99, 'rgb(216, 115, 149)'],
              ],
            },
            markerFillOpacity: 0.7,
            markerLineOpacity: 1,
            markerLineWidth: 3,
            markerLineColor: '#fff',
            markerWidth: {
              property: 'count',
              type: 'interval',
              stops: [
                [0, 40],
                [9, 60],
                [50, 70],
                [99, 80],
              ],
            },
            markerHeight: {
              property: 'count',
              type: 'interval',
              stops: [
                [0, 40],
                [9, 60],
                [50, 70],
                [99, 80],
              ],
            },
          },
          drawClusterText: true,
          geometryEvents: true,
          single: true,
      })

添加marker的代码

 if (isArray(data) && !isEmpty(data)) {
        const markerImg = require('@jdhnw/assets/images/dashboard/soil-position-blue.png')
        const markers = []
        data.forEach((m) => {
          const { latitude, longitude, status, id } = m
          const point = new maptalks.Marker([longitude, latitude], {
            id,
            symbol: [
              {
                markerFile: markerImg,
                markerWidth: 46,
                markerHeight: 32,
              },
            ],
          })
          point.on('click', () => {
            this.map.setCenter([longitude, latitude])
            this.$nextTick(() => {
              const { soildMapDialogRef } = this.$refs
              soildMapDialogRef.open({ type: 'ID', data: { cropCateId: this.filter.cropCategory, quotaDataId: m.id } })
            })
          })
          markers.push(point)
          // 添加聚合图层
          this.clusterLayer.addMarker(point)
          console.log('添加聚合图层: ', point)
        })
        this.map.addLayer(this.clusterLayer)
      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions