我在我的web应用程序上有一个Map,它加载一个geojson文件来显示Map上的属性,这包括140k功能。
当Map缩小时,性能非常慢,我正在寻找如何改进的建议。
我使用的是开放层4。
代码如下:
var SolarData = "";
var solarLayer = new ol.layer.Vector();
//addWards
proj4.defs("EPSG:27700", '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717' +
' +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs');
ol.proj.get('EPSG:27700').setExtent([0, 0, 800000, 1400000]);
ol.proj.get('EPSG:27700').setWorldExtent([-10, 49, 6, 63]);
ol.proj.get('EPSG:27700').setGlobal(false);
ol.proj.get('EPSG:27700').setGetPointResolution(function (resolution) { return resolution; });
var sprojection = new ol.proj.Projection({
code: 'EPSG:900913'
});
var solarProjection = new ol.proj.Projection({
code: 'EPSG:27700',
units: 'm'
});
$.getJSON("/content/property_data.json", function (data) {
SolarData = data;
var solarsource = new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(SolarData),
});
var sfill = new ol.style.Fill({ color: 'rgba(1, 184, 170, 0)' });
var sstyle = new ol.style.Style({
fill: sfill,
stroke: new ol.style.Stroke({
color: '#212121',
width: 2
})
});
var solarFeatures = solarsource.getFeatures();
for (var i = 0; i < solarFeatures.length; i++) {
var feature = solarFeatures[i];
feature.getGeometry().transform(solarProjection, sprojection);
feature.setStyle(sstyle);
feature.set('name', '');
}
solarLayer = new ol.layer.Vector({
source: solarsource,
});
map.addLayer(solarLayer);
}).fail(function (jqXHR, textStatus, errorThrown) {
console.log("error " + textStatus);
console.log("incoming Text " + jqXHR.responseText);
});
暂无答案!
目前还没有任何答案,快来回答吧!