日期:2014-05-16 浏览次数:20727 次
public class Ap { private String id;//编号 private Double longitude;//经度 private Double latitude;//纬度 //getter and setter }
public class ApQueryAction extends MapBaseAction{ private String aps; @Override protected String exec() throws BussinessException { List<Ap> list = mapService.getAp(); Gson gson = new Gson(); aps = gson.toJson(list); return SUCCESS; } //getter and setter
//获得标示物 var markerList = [];//存放标注对象的数组 var markerClusterer;//聚合marker对象 function showAllPoint() { //判断是否存在聚合marker对象,避免重复添加标注 if(markerClusterer){ markerClusterer.removeMarkers(markerList); } //将标注列表清空 markerList=[]; $.ajax({ type: "GET", url: "getAps.do", dataType: "json", success: function(data) { var Aps = eval(data.aps); for(i = 0; i<Aps.length; i++) { var apPoint = new BMap.Point(Aps[i].longitude,Aps[i].latitude); //将新增的marker对象放入数组 markerList.push(new BMap.Marker(apPoint)); //如果使用map.addOverlay(markerList[i])添加大量标注的话会导致浏览器反应速度很慢 //map.addOverlay(markerList[i]); } //使用聚合marker,添加大量标注时性能明显提高 markerClusterer = new BMapLib.MarkerClusterer(map, {markers:markerList}); } }); }