在Openlayers中,可以根据缩放级别打开或关闭某些功能。尽管查看了文档,但我还没有在OpenLayers 3中找到相同的功能。有谁知道如何做到这一点?这是我放置在地图上的功能,ol.style.Text
是我想在用户放大到特定缩放级别后才显示的功能。设置样式缩放级别开放层3
var geoJsonObj = {
'type': 'Feature',
'geometry': JSON.parse(response.FieldList[key].Shape)
}
var vectorSource = new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(geoJsonObj)
});
Fields[Field.FieldID] = new ol.layer.Vector({
projection: 'EPSG:4269',
source: vectorSource,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'yellow',
width: 1
}),
fill: new ol.style.Fill({
color: rcisWebMapUtilities.convertHex(response.FieldList[key].Shade, '0.5')
}),
text: new ol.style.Text({
textAlign: 'Center',
text: response.FieldList[key].Acres,
scale: 1
})
})
});
不'minResolution','maxResolution'矢量层初始化满足您的需求???? api doc here - > http://openlayers.org/en/latest/apidoc/ol.layer.Vector.html – pavlos
不是因为Style是图层的一部分,所以不仅仅是文本隐藏整个图层隐藏... –
那么你可以使用'ol.style.StyleFunction()'而不是静态样式。它接受两个参数'ol.Feature'和'resolution'。因此使用该分辨率可以返回带有或者没有文本的静态样式。如果你需要进一步的帮助,我会尽量做一个小提琴。 – pavlos