第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何使我的 Leaflet js 地圖上的每個(gè)標(biāo)記在懸停并單擊時(shí)運(yùn)行特定功能

如何使我的 Leaflet js 地圖上的每個(gè)標(biāo)記在懸停并單擊時(shí)運(yùn)行特定功能

千萬里不及你 2023-08-18 14:35:34
我有一個(gè)包含點(diǎn)對(duì)象的數(shù)組,我可以從中繪制標(biāo)記。    var Allpoints=[{           "names":"first", "eastings":556568, "northings":446445, "description": "aijaskj jnrkajra skjanjanek ", "elevations": 5668, "LatLong": [10.769869, -2.337035]},{    "names":"first", "eastings":556568, "northings":446445, "description": "aijaskj jnrkajra skjanjanek ", "elevations": 5668, "LatLong":[10.387760, -0.448079]},{    "names":"first", "eastings":556568, "northings":446445, "description": "aijaskj jnrkajra skjanjanek ", "elevations": 5668, "LatLong":[9.104698, -0.882039]},{    "names":"first", "eastings":556568, "northings":446445, "description": "aijaskj jnrkajra skjanjanek ", "elevations": 5668, "LatLong":[5.580339, -2.266316]},{    "names":"first", "eastings":556568, "northings":446445, "description": "aijaskj jnrkajra skjanjanek ", "elevations": 5668, "LatLong":[8.050960, -1.247334]},{    "names":"first", "eastings":556568, "northings":446445, "description": "aijaskj jnrkajra skjanjanek ", "elevations": 5668, "LatLong":[5.142810, -1.961445]},{    "names":"first", "eastings":556568, "northings":446445, "description": "aijaskj jnrkajra skjanjanek ", "elevations": 5668, "LatLong":[6.115865, 0.082012]},            ];繪制標(biāo)記的圖片 
查看完整描述

1 回答

?
拉風(fēng)的咖菲貓

TA貢獻(xiàn)1995條經(jīng)驗(yàn) 獲得超2個(gè)贊

問題是,當(dāng)您在偵聽器中添加一個(gè)函數(shù)并將其添加到該函數(shù)時(shí),()它會(huì)直接執(zhí)行,而不是在執(zhí)行偵聽器時(shí)執(zhí)行。


所以正確的是:_newMarker.addEventListener('click', markerDetails)


將您的代碼更改為:



for (obj in Allpoints){

    _newMarker = L.marker(Allpoints[obj].LatLong, 

        {title: Allpoints[obj].names,

            riseOnHover: true,           

        },

        ).addTo(mymap);

    _newMarker.data = Allpoints[obj]; // save the objectData on the marker

    allMarkers.push(_newMarker);


    _newMarker.on('click', markerDetails);

}


function markerDetails(e){

        var currentMarker = e.target;

        var obj = currentMarker.data; //your objectData

        $("#returnControlName").html(currentMarker.controlName);

        $("#returnControlEastings").html(controlEastings);

        $("#returnControlNorthings").html(controlNorthings);



}



查看完整回答
反對(duì) 回復(fù) 2023-08-18
  • 1 回答
  • 0 關(guān)注
  • 174 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)