更改 openlayers3 缩放灵敏度
change openlayers3 zoom sensitivity
我目前正在使用带有 4 个缩放级别的切片地图 (ol.layer.Tile) 的 OL3。我希望缩放更灵敏,并允许 8 个缩放级别而不是 4 个,每个平铺级别各 2 个。有什么想法吗?
根据 docs,您可以使用 View 对象中的几个属性来管理缩放设置:
- maxResolution: The maximum resolution used to determine the resolution constraint. It is used together with minResolution (or
maxZoom) and zoomFactor. If unspecified it is calculated in such a way
that the projection's validity extent fits in a 256x256 px tile. If
the projection is Spherical Mercator (the default) then maxResolution
defaults to 40075016.68557849 / 256 = 156543.03392804097.
- minResolution: The minimum resolution used to determine the resolution constraint. It is used together with maxResolution (or
minZoom) and zoomFactor. If unspecified it is calculated assuming 29
zoom levels (with a factor of 2). If the projection is Spherical
Mercator (the default) then minResolution defaults to
40075016.68557849 / 256 / Math.pow(2, 28) = 0.0005831682455839253.
- maxZoom: The maximum zoom level used to determine the resolution constraint. It is used together with minZoom (or
maxResolution) and zoomFactor. Default is 28. Note that if
minResolution is also provided, it is given precedence over maxZoom.
- minZoom: The minimum zoom level used to determine the resolution constraint. It is used together with maxZoom (or minResolution) and
zoomFactor. Default is 0. Note that if maxResolution is also provided,
it is given precedence over minZoom.
- zoomFactor: The zoom factor used to determine the resolution constraint. Default is 2.
为 XYZ 源的每个图块网格缩放级别获取 2 个视图缩放级别的示例:
var source = new ol.source.XYZ({
// your source configuration here
});
var resolutions = source.getTileGrid().getResolutions();
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: source
})
],
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 0,
maxResolution: resolutions[0],
minResolution: resolutions[resolutions.length-1],
zoomFactor: 1.5
})
});
我目前正在使用带有 4 个缩放级别的切片地图 (ol.layer.Tile) 的 OL3。我希望缩放更灵敏,并允许 8 个缩放级别而不是 4 个,每个平铺级别各 2 个。有什么想法吗?
根据 docs,您可以使用 View 对象中的几个属性来管理缩放设置:
- maxResolution: The maximum resolution used to determine the resolution constraint. It is used together with minResolution (or maxZoom) and zoomFactor. If unspecified it is calculated in such a way that the projection's validity extent fits in a 256x256 px tile. If the projection is Spherical Mercator (the default) then maxResolution defaults to 40075016.68557849 / 256 = 156543.03392804097.
- minResolution: The minimum resolution used to determine the resolution constraint. It is used together with maxResolution (or minZoom) and zoomFactor. If unspecified it is calculated assuming 29 zoom levels (with a factor of 2). If the projection is Spherical Mercator (the default) then minResolution defaults to 40075016.68557849 / 256 / Math.pow(2, 28) = 0.0005831682455839253.
- maxZoom: The maximum zoom level used to determine the resolution constraint. It is used together with minZoom (or maxResolution) and zoomFactor. Default is 28. Note that if minResolution is also provided, it is given precedence over maxZoom.
- minZoom: The minimum zoom level used to determine the resolution constraint. It is used together with maxZoom (or minResolution) and zoomFactor. Default is 0. Note that if maxResolution is also provided, it is given precedence over minZoom.
- zoomFactor: The zoom factor used to determine the resolution constraint. Default is 2.
为 XYZ 源的每个图块网格缩放级别获取 2 个视图缩放级别的示例:
var source = new ol.source.XYZ({
// your source configuration here
});
var resolutions = source.getTileGrid().getResolutions();
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: source
})
],
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 0,
maxResolution: resolutions[0],
minResolution: resolutions[resolutions.length-1],
zoomFactor: 1.5
})
});