收藏
回答

MapContext.includePoints(Object object)接口无效?

请问MapContext.includePoints(Object object) 属性 Padding在IOS中无效的解决办法或者替代方案?


回答关注问题邀请回答
收藏

3 个回答

  • 社区技术运营专员--Demons
    社区技术运营专员--Demons
    2022-06-10

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2022-06-10
    有用
    回复 2
    • Melancholy
      Melancholy
      2022-06-10
      在模拟器上复现不了, 只能在IOS上出现
      2022-06-10
      回复
    • 小葛
      小葛
      02-07
      includePoints在组件中使用无效
      02-07
      回复
  • 卢依莎
    卢依莎
    04-23
    <template>
      <div class="" ref="mapPage">
        <s-header :back="false" :background="conf.header.background" backText="" title="地图" color="#fff" />
        <map
            class="map"
            id="map"
            :latitude="location.latitude"
            :longitude="location.longitude"
            :markers="markers"
          >
          </map>
      </div>
    </template>
    
    
    <script lang="ts" setup>
    import { onLoad } from '@dcloudio/uni-app'
    import { onMounted, onUnmounted, ref, reactive, nextTick, watch } from "vue"
    import ApiUser from '~/api/ApiUser'
    import CUser from '~/store/CUser'
    import { imgBaseUrl } from '~/utils/config'
    
    
    // 创建自定义样式的图标
    const conf = reactive({
      header: {
        background: '#63BED0'
      }
    })
    const mapPage = ref<any>(null)
    const scale = ref(10.5)
    const location= ref({
        latitude: 39.991104,
        longitude: 116.377503,
    })
    
    
    const markers = ref([
    {
          id: 1,
          latitude: 22.720883956756303,
          longitude: 114.08409655692533,
          joinCluster: true,
          width: 24,
          height: 24,
          iconPath:  imgBaseUrl+'map/point-red.png'
        },{
          id: 2,
          latitude: 22.746092441888514,
          longitude: 114.09979733772285,
          joinCluster: true,
          width: 24,
          height: 24,
          iconPath:  imgBaseUrl+'map/point-red.png'
        },{
          id: 3,
          latitude: 22.690677266436236,
          longitude: 114.1013920681209,
          joinCluster: true,
          width: 24,
          height: 24,
          iconPath:  imgBaseUrl+'map/point-red.png'
        },{
          id: 9,
          latitude: 22.626980627299076,
          longitude: 113.9763082398972,
          joinCluster: true,
          width: 24,
          height: 24,
          iconPath:  imgBaseUrl+'map/point-red.png'
        },{
          id: 4,
          latitude: 40.040417,
          longitude: 116.373514,
          joinCluster: true,
          width: 24,
          height: 24,
          iconPath:  imgBaseUrl+'map/point-red.png'
        },{
          id: 5,
          latitude: 39.953416,
          longitude: 116.380945,
          joinCluster: true,
          width: 24,
          height: 24,
          iconPath:  imgBaseUrl+'map/point-red.png'
        },{
          id: 6,
          latitude: 39.984104,
          longitude: 116.307503,
          joinCluster: true,
          width: 24,
          height: 24,
          iconPath:  imgBaseUrl+'map/point-red.png'
        },{
          id: 7,
          latitude: 39.908802,
          longitude: 116.397502,
          joinCluster: true,
          width: 24,
          height: 24,
          iconPath:  imgBaseUrl+'map/point-red.png'
        },{
          id: 8,
          latitude: 40.040417,
          longitude: 116.273514,
          joinCluster: true,
          width: 24,
          height: 24,
          iconPath:  imgBaseUrl+'map/point-red.png'
        }
    ])
    
    
    onMounted(() => {
      const mapCtx = wx.createMapContext('map', this);
        mapCtx.initMarkerCluster({
          gridSize:30,
          zoomOnClick: true
        });
    
    
        // 自动调整视野
      setTimeout(() => {
        mapCtx.includePoints({
          points: markers.value.map(m => ({
            latitude: m.latitude,
            longitude: m.longitude
          })),
          padding: { left: 40, right: 40, top: 100, bottom: 40 },
          success: () => {
            console.log(111111);
          },
          fail: (err: any) => {
            console.log(err, 2222222);
          }
        })
      }, 5000) // 添加适当延时确保地图初始化完成
    
    
    })
    
    
    onLoad(() => {
      
    })
    </script>
    <style lang="less" scoped>
    
    
    .map {
      width:100%;
      height:calc(100vh - 40rpx);
      position: relative;
    }
    </style>
    
    
    04-23
    有用
    回复 2
    • 卢依莎
      卢依莎
      04-23
      我是这样写的,mapCtx.includePoints ,真机和开发者工具都无效,没有执行回调
      04-23
      回复
    • 卢依莎
      卢依莎
      04-23
      我在评论区看到答案了,在组件中使用无效
      04-23
      回复
  • 茜茜又困了🐽
    茜茜又困了🐽
    2022-06-10

    上代码,怎么个无效?

    2022-06-10
    有用
    回复 8
    • Melancholy
      Melancholy
      2022-06-10
      2022-06-10
      回复
    • Melancholy
      Melancholy
      2022-06-10
      地图的4个方向设置不了padding, includePoints包含坐标点之后, marker标记点会超出地图
      2022-06-10
      回复
    • 茜茜又困了🐽
      茜茜又困了🐽
      2022-06-10回复Melancholy
      2022-06-10
      回复
    • 茜茜又困了🐽
      茜茜又困了🐽
      2022-06-10回复Melancholy
      四个方向的padding都设置上试试呢?
      2022-06-10
      1
      回复
    • Melancholy
      Melancholy
      2022-06-10回复茜茜又困了🐽
      解决了, 谢谢大佬
      2022-06-10
      1
      回复
    查看更多(3)
登录 后发表内容