气象台发布的雷达拼图时效性好,范围广,可以用来作为一个较好的拼图数据源。
方法:
1.定时下载拼图,如下图:
2.重投影,重新生成麦卡托投影产品。
3.使用openlayers叠加静态图像,生成效果如下:
叠加显示拼图的代码如下:
mounted() {
// // 1.创建鼠标控件
var mouse = new MousePosition({
coordinateFormat: createStringXY(4),
projection: 'EPSG:4326', // 地图投影坐标系
className: 'custom-mouse-position', // 自定义显示样式
target: document.getElementById('pos'),
undefinedHTML: ' '
});
this.center = fromLonLat([113.111, 23.222]);
this.view = new View({
center: this.center,
zoom: 4
});
this.map = new Map({
target: "mapDiv",
layers: [
new TileLayer({
source: new OSM()
}),
new ImageLayer({
source: new ImageStatic({
//引用最新的拼图产品
url: curUrl,
projection: "EPSG:3857",
imageExtent: Proj.transformExtent([70, 0, 140, 55], 'EPSG:4326', 'EPSG:3857')
})
})
],
view: this.view
});