Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Curreter opened this issue Feb 21, 2024 · 0 comments

Comments

@Curreter
Copy link

在生产环境中聚合图层和添加到聚合图层中的所有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)
      }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant