javascript - Openlayers/Openstreetmap 背景是垂直条纹和压扁的

标签 javascript maps openlayers openstreetmap

因此,我的 openlayers 实现的背景似乎被压成垂直条纹。奇怪的是,它并不总是这样,但即使我将所有更改存储回我知道它正在工作的地方,它仍然是坏的。这让我想知道瓷砖 Assets 的交付方式是否发生了变化。我已经尝试在使用 osm 和 wms 层之间切换而没有任何变化,我们将不胜感激。

相关代码如下:

initMap: function() {
  var view = this;
  var map = this.map = new OpenLayers.Map();
  map.render(this.$map[0]);

  var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
    "http://vmap0.tiles.osgeo.org/wms/vmap0?", {layers: 'basic'});

  var osmLayer = new OpenLayers.Layer.OSM();

  this.layers = {
    point: new OpenLayers.Layer.Vector("Point Layer"),
    line: new OpenLayers.Layer.Vector("Line Layer"),
    polygon: new OpenLayers.Layer.Vector("Polygon Layer")
  };

  this.setValue(this.value);

  map.addLayers([this.layers.point, this.layers.line, this.layers.polygon, osmLayer]);

  drawControls = {
    point: new OpenLayers.Control.DrawFeature(this.layers.point,
      OpenLayers.Handler.Point),
    line: new OpenLayers.Control.DrawFeature(this.layers.line,
      OpenLayers.Handler.Path),
    polygon: new OpenLayers.Control.DrawFeature(this.layers.polygon,
      OpenLayers.Handler.Polygon)
  };

  this.layers[this.layerType].events.on({'sketchcomplete': function(feature) {

    if (!view.multiple) {
      // deactivate polygon layer once a polygon has been added
      drawControls[view.layerType].deactivate();
    }

  }});

  for(var key in drawControls) {
    map.addControl(drawControls[key]);
  }

  if (this.layers[this.layerType].features.length) {
    var bounds = this.layers[this.layerType].getDataExtent();
    var zoom = this.layers[this.layerType].getZoomForExtent(bounds);
    var lon = (bounds.top - bounds.bottom) / 2;
    var lat = (bounds.right - bounds.left) / 2;
    map.setCenter(new OpenLayers.LonLat(lon,lat), 3);
    map.zoomToExtent(bounds);

    if (view.multiple) {
      drawControls[view.layerType].activate();
    }

  } else {
    map.setCenter(new OpenLayers.LonLat(-11174482.03751,4861394.9982606), 4);
    drawControls[view.layerType].activate();
  }

  this.$('.clear').click(function(e) {
    e.preventDefault();
    view.layers[view.layerType].destroyFeatures();
    drawControls[view.layerType].activate();
  });
},

这是输出:

here is the output

最佳答案

所以我发现了问题。 Twitter Bootstrap 在其重置文件中有一行设置:

img { max-width: 100% }

这会压缩图像。您可以通过以下方式修复它:

img { max-width: none; }

关于javascript - Openlayers/Openstreetmap 背景是垂直条纹和压扁的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11266297/

相关文章:

javascript - 获取 OpenLayers 中 2 个 LonLat 对象之间的像素距离

javascript - 缩小至最低范围的 bing map 不适合 map 区域

javascript - Electron JS中的capturePage

javascript - on.Click 事件不会在简单代码上触发

javascript - 如何在 React 组件中调用 minimize() 和 focus()?

删除美国州界,在 ggplot2/geom_polygon 中创建轮廓区域

go - Golang 中有等效的 Guava 表吗?如果不是,在 Go 中正确的做法是什么

javascript - 特殊字符验证

struct - 将字符串转换为字段名称

javascript - 如何将特定国家/地区的 map 加载到 OpenStreetMap 中?