一个地图,可能有很多图层。以交通层为例,如下:
var map = new BMap.Map("container");
var point = new BMap.Point(123.123, 12,123);
map.centerAndZoom(point, 15);
map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.ScaleControl());
map.addControl(new BMap.OverviewMapControl());
map.addControl(new BMap.MapTypeControl);
map.setCurrentCity("北京");
var traffic = new BMap.TrafficLayer();
map.addTileLayer(traffic);
如上所述,创建图层的命令是:
var traffic = new BMap.TrafficLayer();
向地图添加图层的命令是:
map.addTileLayer(traffic);
从地图删除图层的命令是:
map.removeTileLayer(traffic);