微信公众号开发

微信小程序map组件callout与label简单用法

本文主要是介绍微信小程序map组件callout与label简单用法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

callout和label的效果图
在这里插入图片描述
在这里插入图片描述
callout初始位置在标记上方 label初始位置在标记右下方

data:{
	marker:[{
		//气泡label
		label:{
        		content: ‘预约’,  //文本
        		color: '#FF0202',  //文本颜色
        		borderRadius: 3,  //边框圆角
       			borderWidth: 1,  //边框宽度
        		borderColor: '#68c4c7',  //边框颜色
       			bgColor: '#ffffff',  //背景色
       			padding: 5,  //文本边缘留白
       			textAlign: 'center'  //文本对齐方式  left, right, center
      	},
      	//气泡callout
      	callout: {
        		content: '预约',  //文本
       	 		color: '#FF0202',  //文本颜色
        		borderRadius: 3,  //边框圆角
       			borderWidth: 1,  //边框宽度
       			borderColor: '#FF0202',  //边框颜色
       			bgColor: '#68c4c7',  //背景色
       			padding: 5,  //文本边缘留白
       			textAlign: 'center'  //文本对齐方式  left, right, center
   		}
	}]
}

另外可用参数anchorY, anchorX调整纵向和横向的位移
在这里插入图片描述
用callout有个问题就是如果marker过多 会导致callout被遮挡 官方文档没有提及zindex等参数调整层级 点击当前标记也没用 但是用label可以解决

这篇关于微信小程序map组件callout与label简单用法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!