OpenLayers time to layer(时间控制)
OpenLayers time to layer (time control)
我是 OpenLayers 的新手,我想要一些东西(日期+时间)并在地图上获取(图层)
例如,我有 (15.02.2010)、(16.02.2010) 等天气的图层。
例如..用户输入(日期+时间)和结果(地图上同一日期的图层)
有什么想法吗?例子? API!
<input type="text" name="customParam" id="customParam">
<button onclick="showIt()">show it</button>
<script>
let source = null;
const map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
function showIt() {
const customParam = document.getElementById("customParam").value;
const isNew = (!source);
if(isNew) {
source = new ol.source.XYZ();
}
source.setUrl(`https://{a-c}.MY-TILES.com/{z}/{x}/{y}.png?myTimeParam=${customParam}`);
source.refresh();
if(isNew) {
map.addLayer(new ol.layer.Tile({ source: source }));
}
}
</script>
我是 OpenLayers 的新手,我想要一些东西(日期+时间)并在地图上获取(图层)
例如,我有 (15.02.2010)、(16.02.2010) 等天气的图层。
例如..用户输入(日期+时间)和结果(地图上同一日期的图层)
有什么想法吗?例子? API!
<input type="text" name="customParam" id="customParam">
<button onclick="showIt()">show it</button>
<script>
let source = null;
const map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
function showIt() {
const customParam = document.getElementById("customParam").value;
const isNew = (!source);
if(isNew) {
source = new ol.source.XYZ();
}
source.setUrl(`https://{a-c}.MY-TILES.com/{z}/{x}/{y}.png?myTimeParam=${customParam}`);
source.refresh();
if(isNew) {
map.addLayer(new ol.layer.Tile({ source: source }));
}
}
</script>