为了方便更换地图,这里选择所有demo共用一个地图js文件,根据所发服务配置好。
在demo中引用此js文件在demo中加载地图时,使用引用文件如下:
//实例化Map对象加载地图
varprojection =ol.proj.get(basemapconfig[0].projection);
projection.setExtent([-180,-90,180,90]);
varview =newol.View({
projection: basemapconfig[0].projection,
resolutions: basemapconfig[0].resolutions,
center: center_zoom.section2.center,
zoom: center_zoom.section2.zoom
});
varmap =newol.Map({
projection:basemapconfig[0].projection,
target:'map',
layers: [
newol.layer.Tile({
source:newol.source.ESRICache({
origin: basemapconfig[0].origin,
resolutions: basemapconfig[0].resolutions,
projection: basemapconfig[0].projection,
url:basemapconfig[0].url+'/tile/{z}/{y}/{x}'
})
})
],
view: view
});
网友评论