我正在尝试从网页中的地理服务器加载 map ,加载时它几乎自身翻倍。第一张 map 是地理服务器管理页面的预览,第二张 map 是在网页上拉出时如何加载它。
最佳答案
我最终通过在图层中添加一些属性来解决这个问题,这是我的代码:
mapInit: function() {
var _this = this;
this.map = new ol.Map({
target: 'mapdiv', //element to render in
interactions: ol.interaction.defaults({
shiftDragZoom: false,
altShiftDragRotate: false,
dragPan: false
}),
controls: ol.control.defaults({
attributionOptions: ({
collapsible: true
})
}).extend([ new ol.control.ScaleLine() ]),
renderer: 'canvas',
layers: [
new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://***.**.**.***:8080/geoserver/Global/wms',
params: {'LAYERS': 'Global Map', 'TILED': true},
noWrap: true, //<----added this
wrapX: false //<----added this
}),
//constrain the extent of the servable tiles to only 1 world's coordinates.
extent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34] //<----added this
})
],
关于javascript - 为什么 OpenLayers-3 加载过多 map ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28077183/