gpt4 book ai didi

zooming - 我希望 map 只显示荷兰

转载 作者:行者123 更新时间:2023-12-04 01:16:55 27 4
gpt4 key购买 nike

这是我加载 map 的 init 函数,我希望它只显示荷兰,应该可以放大但不应该缩小。我到处搜索,但找不到有关如何执行此操作的正确解释。

var config = {
zoom: 14,
zoomStart: 8,
centerPoint: new OpenLayers.LonLat(622044.536098, 6797086.3022847),
strokeColor: "#941B80",
strokeColor_allloc: "#575757",
strokeOpacity: 0.8,
strokeOpacity_allloc: 0.9,
strokeWeight: 2,
trackWeight: 5,
fillColor: "#941B80",
fillColor_allloc: "#575757",
fillOpacity: 0.25,
fillOpacity_allloc: 0.40,
pointRadius: 5,
fontColor: "black",
fontSize: 10,
fontFamily: "Arial",
scaleFactor: 1000000,
extent: new OpenLayers.Bounds(-5037508, -5037508, 5037508, 5037508.34),
units: 'm',
resolution: 156543.0339,
displayProjection: new OpenLayers.Projection("EPSG:4326"),
projection: new OpenLayers.Projection("EPSG:900913"),
controls: [
new OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoomBar(), new OpenLayers.Control.Attribution()],
copyright: 'Map data &copy; 2010 <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a><br /><a href="http://openstreetmap.org">OpenStreetMap.org</a> contributors',
numZoomLevels: 10,
numberPlateTail: new OpenLayers.Size(117.333, 42),
numberPlate: new OpenLayers.Size(117.333, 25),
iconSize: new OpenLayers.Size(32, 37)
};

var myLayers = {
base: new OpenLayers.Layer.OSM('', '', {
attribution: config.copyright,
transitionEffect: 'resize',
layers: 'basic'
}, {
isBaseLayer: true
}),
vector: new OpenLayers.Layer.Vector('Vormen aan/uit', {
styleMap: my_style,
renderers: ['Canvas', 'SVG', 'VML']
}),
allloc_vector: new OpenLayers.Layer.Vector('Vormen aan/uit', {
styleMap: my_style,
renderers: ['Canvas', 'SVG', 'VML']
}),
markers: new OpenLayers.Layer.Markers('Markers')
};
init: function (canvas) {
this.canvas = canvas;
$('#' + canvas).append('<input type="button" class="button" value="Volledig scherm" onclick="tbMap.toggleFs();" />');
this.map = new OpenLayers.Map(this.canvas, {
controls: config.controls,
displayProjection: config.displayProjection,
Projection: config.projection,
maxExtent: config.extent,
maxResolution: config.resolution,
units: config.units,
numZoomLevels: config.numZoomLevels,
theme: null
});
tbMap.zoom();
this.map.addLayers([myLayers.base, myLayers.vector]);
this.map.setCenter(config.centerPoint, config.zoomStart);
},
zoom: function () {
OpenLayers.Control.Navigation.prototype.counter = 0;
//Inzoomgevoeligheid
OpenLayers.Control.Navigation.prototype.wheelUp = function (evt) {
this.counter++;
if (this.counter > 2) {
this.counter = 0;
this.wheelChange(evt, 1);
}
};
//Uitzoomgevoeligheid
OpenLayers.Control.Navigation.prototype.wheelDown = function (evt) {
this.counter--;
if (this.counter < -2) {
this.counter = 0;
this.wheelChange(evt, -1);
}
};
},

最佳答案

您可以设置配置属性 maxExtent .在配置中使用现有的边界,它看起来像这样,

maxExtent : new OpenLayers.Bounds(-5037508, -5037508, 5037508, 5037508.34)

您可以在初始化时将其添加到 map 配置中。

您可能还想查看 restrictedExtent

希望这可以帮助

关于zooming - 我希望 map 只显示荷兰,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10997544/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com