当你的才华还撑不起你的梦想时,你只能一直前进!

记录---百度地图marker中label现隐

 1 var marker = new BMap.Marker(point, {
 2    icon: new BMap.Icon('', new BMap.Size(16, 16), {
 3      anchor: new BMap.Size(9, 9)        
 4    }) 
 5 })
 6 
 7 var content = '<span>'+xxxxx+'</span>
 8 
 9 var label = new BMap.Label(content, {
10    offset: new BMap.Size(0, 0) 
11 })
12 label.setStyle({
13    border: '1px solid rgba(204, 204, 204, 0)',
14    color: 'rgb(0, 255, 255)',
15    borderRadius: '10px',
16    padding: '5px',
17    background: 'rgba(21, 21, 21, 0.5)',
18    display: 'none'
19 })
20 
21 marker.setLabel(label)
22 marker.addEventListener('mouseover', function () {
23    marker.getLabel().setStyle({display: 'block'})
24 })
25 marker.addEventListener('mouseout', function () {
26    marker.getLabel().setStyle({display: 'none'})
27 })
28 
29 map.addOverlay(marker)

 

posted @ 2019-09-30 16:15  One'-_-'Piece  阅读(453)  评论(0编辑  收藏  举报