微信小程序聚合点有的坐标不能被聚合的问题?
发布于 6 年前 作者 linyang 11067 次浏览 来自 问答

小程序map组件

版本号:2.14.0

两组坐标,有一组能出现聚合点,一组却不能出现聚合点这是什么问题呢?

上图已实现聚合且坐标点为:

var customCallout1 = {
  id: 43,
  latitude: 23.169401,
  longitude: 113.157806,
  iconPath: '../image/location.png',
  width:60,
  height:60,
  joinCluster: true,
  customCallout: {
    anchorY: 0,
    anchorX: 0,
    display'BYCLICK'
  },
}

var customCallout2 = {
  id: 345,
  latitude: 23.096994,
  longitude: 113.324520,
  iconPath: '../image/location.png',
  width:60,
  height:60,
  joinCluster: true,
  customCallout: {
    anchorY: 0,
    anchorX: 0,
    display'BYCLICK',
  },
}

var customCallout3 = {
  id:3434,
  latitude: 23.095994,
  longitude: 113.325520,
  iconPath: '../image/location.png',
  width:60,
  height:60,
  joinCluster: true,
  customCallout: {
    anchorY: 0,
    anchorX: 0,
    display'BYCLICK',
  },
}

上图没有聚合效果,坐标点为:

var customCallout4 = {
  id: 43,
  latitude:  36.071302,
  longitude: 111.498871,
  iconPath: '../image/location.png',
  width:60,
  height:60,
  joinCluster: true,
  customCallout: {
    anchorY: 0,
    anchorX: 0,
    display'BYCLICK'
  },
}

var customCallout5 = {
  id: 345,
  latitude: 36.143753,
  longitude: 111.431881,
  iconPath: '../image/location.png',
  width:60,
  height:60,
  joinCluster: true,
  customCallout: {
    anchorY: 10,
    anchorX: 0,
    display'BYCLICK',
  },
}

这两份marker其他参数都是一样的,为什么不形成聚合点呢

map组件初始化

//var allMarkers = [customCallout1, customCallout2, customCallout3]
var allMarkers = [customCallout4, customCallout5]

Page({
  data: {
    // latitude: 23.096994,
    // longitude: 113.324520,
    latitude36.088228,
    longitude111.518949,
  },
  onLoadfunction () {
    this.mapCtx = wx.createMapContext('myMap');
    this.mapCtx.addMarkers({
      markers:allMarkers,
      clearfalse,
      fail(res){
        console.log(res);
      },
      complete(res) {
        console.log('addMarkers', res)
      }
    })
  },
  markertap(e) {
    console.log('@@@ markertap', e)
  },
})

wxml文件

<view class="page-body">
  <view class="page-section page-section-gap">
    <map
      id="myMap"
      style="width: 100%; height: 300px;"
      latitude="{{latitude}}"
      longitude="{{longitude}}"
      bindmarkertap="markertap"
      scale="10"
    >
      <!-- <cover-view slot="callout">
        <block wx:for="{{markers}}" wx:key="item.id">
          <cover-view  class="customCallout" marker-id="{{item.id}}" >
            <cover-image class="icon" src="/image/voice.png"></cover-image>
            <cover-view class="content"> 
              {{num}}-{{item}}-{{index}}
            </cover-view>
          </cover-view>
        </block>
      </cover-view> -->
    </map>
  </view>
</view>
1 回复

你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部