百度地图中的point上添加label文字

 content:文字内容

point:在该经纬度处添加文字

function setLabelStyle(content, point) {
        var label = new BMapGL.Label("<span class='my-maptip'>" + content + '<br /><span>', // 为lable填写内容
          {
            offset: new BMapGL.Size(-8, -10), // label的偏移量,为了让label的中心显示在点上
            position: point
          } // label的位置
        )
        var size = '10px'
        if (that.map.getZoom() <= 15.5) {
          size = '0px'
        }
        var labelStyle = {
          border: '0',
          fontSize: size,
          height: '20px',
          lineHeight: '20px',
          fontFamily: '微软雅黑',
          backgroundColor: '0.05',
          fontWeight: 'bold',
        }
        label.setStyle(labelStyle)
        that.map.addOverlay(label)
      }

猜你喜欢

转载自blog.csdn.net/qq_46372045/article/details/127844868
今日推荐