Arcgis api for javascript 图层的获取与更替
方法一:
在function init()中:
…… var landusePointLayer = new esri.layers.FeatureLayer("http://10.0.0.28/arcgis/rest/services/editFeature/FeatureServer/0", { mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"], id: "HotspotLayer" }); map.addLayers([landusePointLayer]); …… //直接获取指明的layer var featureHotspotLayer = map.getLayer("HotspotLayer");
var featurelayers=map.getLayer(map.layerIds[2]);
map.removeLayer(map.getLayer(map.layerIds[0]));
//例子,更替底图层
function mapBaseEsri(){
dojo.addOnLoad(function(){
map.removeLayer(map.getLayer(map.layerIds[2]));
tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer");
map.addLayer(tiledMapServiceLayer);
});
}
方法二:
//全局变量 var basemap1 ;
function getlsLayer(){ dojo.addOnLoad(function(){ basemap1 = new esri.layers.ArcGISDynamicMapServiceLayer("http://mapservice.agrolib.com/ArcGIS/rest/services/wl_ChinaBasicMap/MapServer"); map.addLayer(basemap1); }); } function lsClearClick(){//removerlsLayer(){ dojo.addOnLoad(function(){ map.reorderLayer(basemap1); }); }
作者:爱ai优酷
出处:http://www.cnblogs.com/aiyouku/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。