maptalks / maptalks/maptalks.markercluster
在生产环境中聚合图层和添加到聚合图层中的所有marker同时显示出来, 在开发环境中又是正常的
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 49
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
在生产环境中聚合图层和添加到聚合图层中的所有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)
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the production-only behavior using the shown ClusterLayer initialization and the loop that calls clusterLayer.addMarker(point), then compare it with the development build. Confirm that production renders clustered markers without also rendering every individual marker; the issue provides no named files or tests to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100