高德地圖WEB開發POI搜索結果的點擊事件

```

//點擊地圖上的點標記

AMap.event.addListener(placeSearch,"markerClick",function(e) {

? ??isOutOfPath(e);

????console.log(e.data.location);//當前marker的經緯度信息

? ? console.log(e.data.location.lng +',' + e.data.location.lat);

????console.log(e.data.address);//獲取當前marker的具體地址信息

? ? console.log(e.data);//則是包含所有的marker數據

});

//點擊panel列表的點標記

AMap.event.addListener(placeSearch,"listElementClick",function(e) {

????isOutOfPath(e);

????console.log(e.data.location);//當前marker的經緯度信息

? ? console.log(e.data.location.lng +',' + e.data.location.lat);

????console.log(e.data.address);//獲取當前marker的具體地址信息

? ? console.log(e.data);//則是包含所有的marker數據

});

//判斷選中的點是否在面內部,polygons為這個變形集合

function isOutOfPath(e){

var point = e.marker.getPosition();

var isPointInRing=false;

for(var j=0;j<polygons.length;j++){

if(AMap.GeometryUtil.isPointInRing(point,polygons[j].getPath())){

isPointInRing=true;

}

}

e.marker.setLabel({

content:isPointInRing?'派送范圍內部':'超出配送范圍',

offset:new AMap.Pixel(20,0)

});

}

/*

* 獲取某一類覆蓋物

* */

function getAllOverlays(type) {

return map.getAllOverlays(type);

}

```

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容