이것은지도를로드하는 제 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 © 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);
}
};
},
이미 restrictedExtent 및 maxExtent을 시도했지만 이것으로 당신은 여전히 더 축소 할 수 있습니다 . 제한된 유일한 것은 패닝입니다. – Pepijn
@Pepijn은 시도한 것을 나열 할 수 있습니까? 이 페이지를 보셨습니까? http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels –
목록에서 모든 것을 시도했지만 OSM과 호환되지 않는 것으로 보입니다. 회피와 패치가있는 웹 사이트를 찾았습니다. 그들이 새로운 openlayers 버전에서 이것을 수정할 때까지 기다릴 것입니다. – Pepijn