web开发高德地图marker的label重叠了,怎么让label不重叠显示?

问题描述

web开发高德地图marker的label重叠了,怎么让label不重叠显示?

clipboard.png

问题出现的环境背景及自己尝试过哪些方法

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)
marker = new SimpleMarker({

      //直接使用dom节点
      iconStyle: '<div style="background:gray;width:50px;height:20px;border-radius:10px;"></div>',
      //图标文字
      iconLabel: {
        innerHTML: realName,
      },

      map: map,

      position: [lng, lat],

      showPositionPoint: false,

      // 以 icon 的 [center bottom] 为原点
      offset: new AMap.Pixel(-30, -10)
    });
      marker.setLabel({
        //修改label相对于maker的位置
        offset: new AMap.Pixel(-15, -23),

        content: "<div style='width:80px;'><div class='direction' style='float:left;-webkit-transform:rotate(" + direction + "deg);'></div><div style='float:left;'>&nbsp;&nbsp;&nbsp;&nbsp;"  + stayTime + "min" + "</div></div>"
      });
    }

你期待的结果是什么?实际看到的错误信息又是什么?

能让maeker的label不重叠地显示,比如左边一个右边一个,而不是写死的

阅读 8.2k
1 个回答

你可能需要自己设置一个算法做调整,设置偏移。
或则按类型设置偏移

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题