前置条件:添加百度地图引用url,引用jQuery的js
var test= [];
$.ajax({
type: "GET/POST",
url: "",
async: false(true为异步,默认是异步),
data: 参数,
success: function (msg) {
for (var i = 0; i < msg.Table.length; i++) {
test.push(msg.Table[i]);
}
}
});
//-------------------------------------------
var map = new BMap.Map("div的ID", { enableMapClick: false });//创建地图实体
map.centerAndZoom("point或者城市名", 城市级别(百度是3-19));
if (document.createElement('canvas').getContext) {
var tests= [];
for (var i = 0; i < test.length; i++) {// 添加海量点数据
tests.push(new BMap.Point(Longitude,Latitude););
}
var options = {// 地图显示图标样式
size: BMAP_POINT_SIZE_BIGGER,
shape: BMAP_POINT_SHAPE_STAR,
color: '#F74E41'
}
var pointCollection = new BMap.PointCollection(tests, options );
pointCollection.addEventListener('click', function (e) {
for (var i = 0; i < tests.length; i++) {
//可以拼接html
}
});
map.addOverlay(pointCollection ); // 添加Overlay