1.获取数据
queryData(){//调用接口查询城市数据
let params={time:this.selectedTime,type:this.timeType};
Promise.all([getAllCityAirMoniListOnChina(params), getAllSiteAirMoniListOnChina(params)]).then(res => {
if (res[0].success&& res[1].success) {
this.cityArr = res[0].result.length>0?res[0].result:[];
this.siteArr = res[1].result.length>0?res[1].result:[];
this.drawMapLayer();
//this.processingData();
}
})
},
2.设置地图
setMap1(){
//到 mapbox 官网注册并创建下面的access token都是免费的,不过有5w次的浏览限制
var url = 'http://124.163.214.106:18065/arcgis/rest/services/shenjie_bg/MapServer/tile/{z}/{y}/{x}';
//初始化 地图
//map = L.map('mapid').setView([35.717, 112.6333], 5);
map = L.map("mapid", {//添加
minZoom: 5,//最小缩放值
maxZoom: 12,//最大缩放值
crs: L.CRS.EPSG3857,//几乎所有免费和商业磁贴提供商都使用的最常见的在线地图CRS。使用球形墨卡托投影。在地图crs选项中默认设置。
center: this.centerpoint,//中心坐标
zoom: this.zoomlevel,//默认缩放等级
fullscreenControl: false,
zoomControl: false,//缩放控件不添加
attributionControl: false//归因控件不添加
});
this.baseLayer=L.tileLayer("http://124.163.214.106:18065/arcgis/rest/services/shenjie_bg/MapServer/tile/{z}/{y}/{x}");//基础图层添加
map.addLayer(this.baseLayer);
this.imageLayer =L.imageOverlay('', this.imageBounds,{opacity:0.8});//天气颜色图层
map.addLayer(this.imageLayer);
this.chinaLineLayer=L.tileLayer("http://124.163.214.106:18065/arcgis/rest/services/shenjie/MapServer/tile/{z}/{y}/{x}",{pane: 'overlayPane'});//城市图层
map.addLayer(this.chinaLineLayer);
//this.graphicLayer = L.layerGroup([]);
//map.addLayer(this.graphicLayer);
//将图层加载到地图上,并设置最大的聚焦还有map样式
/* L.tileLayer(url, {
minZoom: 5,
maxZoom: 12,
id: 'mapbox.streets'
}).addTo(map);
map.addLayer(L.tileLayer(&