實現點擊百度地圖上的覆蓋物,而後獲取覆蓋上的屬性,進而實現數據傳送。javascript
var pointArray=new Array();//建立一個數組存儲座標 /*在地圖上標點*/ function ShowAllPoint(){ $.ajax({ type: "GET", url: "http://localhost:27731/api/Welcome/ShowAllPoint", data: {}, dateType: "json", params:{"contentType": "application/json;charset=utf-8"}, success: function (data) { for(var i=0;i < data.length;i++){ //建立點 marker = new BMap.Marker(new BMap.Point(data[i].Longitude,data[i].Latitude)); //增長點 map.addOverlay(marker); pointArray[i]=new BMap.Point(data[i].Longitude,data[i].Latitude); var _id=data[i].Id; marker.customData={id:_id};//自定義參數id marker.addEventListener("click",attribute); } }, error:function(data) { layer.msg(data.msg,{icon:2,time:3000}); }, });