SuperMap建立標註,點選標註彈窗顯示資訊
var markers=new SuperMap.Layer.Markers("Markers",{}); var marker; function processData(data) { //呼叫了processData函式 markers.clearMarkers(); //清空標註 var pointFeature; var pointFeatures=[]; if (data != null && data.length >= 0) { var picture; $.each(data, function (index, info) { //遍歷資料 var id = info.caseSystemId;
map.addLayer(markers); //標記圖層上新增標記 var size = new SuperMap.Size(21,25); var offset = new SuperMap.Pixel(-(size.w/2), -size.h); var icon = new SuperMap.Icon('${staticUrl}/images/change.png' ,size,offset); //設定標註圖片 marker=new SuperMap.Marker(new SuperMap.LonLat(info.longitude,info.latitude),icon); markers.addMarker(marker);
marker.events.register('click', marker, function(){ //標註點選事件 map.removeAllPopup(); //清空彈窗 rowShow(id); //呼叫彈窗方法 });
});
} }
//彈窗方法
function rowShow(id) { map.removeAllPopup(); //清空彈窗 if (type == tipIds.ajxx) { $.ajax({ type: "POST", url: "${ctx}/law/clueInfo/view/letDetail", data: {"letId": id}, dataType: "json", contentType: "application/x-www-form-urlencoded; charset=UTF-8", success: function (data) { map.setCenter(new SuperMap.LonLat(data.longitude, data.latitude),16); //地圖中心 var content = getBubbleTemplate(data); //這裡呼叫的是彈窗的html程式碼