[英]OL3: force loading of source
我有一個設置了maxResolution的圖層,這樣該圖層僅在您按特定級別放大時才顯示。 我的問題是僅在該級別縮放時才加載圖層源數據。 有沒有辦法預加載矢量源數據?
var source = new ol.source.Vector({
url: '/mapsource/source.geojson',
format: new ol.format.GeoJSON()
});
// how do I force loading the source here, and not wait for the map to render at 80 zoom?
var layer = new ol.layer.Vector({
title: 'Test layer',
source: source,
style: my_style,
maxResolution: 80
});
您可以通過ajax加載數據並添加到源中。
var source = new ol.source.Vector();
$.getJSON('/mapsource/source.geojson').done(function(data){
var features = (new ol.format.GeoJSON()).readFeatures(data);
source.addFeatures(features);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.