百度地图标点鼠标样式更改
生活随笔
收集整理的這篇文章主要介紹了
百度地图标点鼠标样式更改
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
需求:修改百度地圖紅點懸停鼠標樣式,有鏈接的鼠標懸停顯示為pointer點擊跳轉(zhuǎn),沒有鏈接的紅點懸停后顯示鼠標默認樣式。
分析1:
百度地圖官方JSAIP2.0?http://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a3b2
百度地圖JS 核心對象:
API方法查找與鼠標相關(guān)的方法:
| 事件 | 參數(shù) | 描述 |
| click | event{type, target} | 點擊標注圖標后會觸發(fā)此事件 |
| dblclick | event{type, target, point,pixel} | 雙擊標注圖標后會觸發(fā)此事件 |
| mousedown | event{type, target, point,pixel} | 鼠標在標注圖上按下觸發(fā)此事件 |
| mouseup | event{type, target, point,pixel} | 鼠標在標注圖上釋放觸發(fā)此事件 |
| mouseout | event{type, target, point,pixel} | 鼠標離開標注時觸發(fā)此事件 |
| mouseover | event{type, target, point,pixel} | 當鼠標進入標注圖標區(qū)域時會觸發(fā)此事件 |
分析2:
默認百度地圖該實例紅點鼠標懸停為小手(pointer)樣式,添加mouseover事件,找到紅點dom對象控制其css
查看mouseover事件的參數(shù),F12后查看找到紅點dom對象的style,嘗試后找到為止為type.currentTarget.V.style。
最終解決代碼:
marker.addEventListener("mouseover", function(type, target, point,pixel){ //console.log(type);type.currentTarget.V.style.cursor ="default";});?
總結(jié)
以上是生活随笔為你收集整理的百度地图标点鼠标样式更改的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JAVA练习题17:文字版格斗游戏
- 下一篇: XY6762/XY6765/XY8788