从打开的图层中移除图层不起作用

时间:2015-06-15 06:46:40

标签: javascript openlayers-3

我正在尝试从GeoServer添加图层;它工作正常,但删除图层不起作用。这是我的代码:

function loadTOCLayer(layerName) {
  var tl = new ol.layer.Tile({
    extent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
    source: new ol.source.TileWMS( /** @type {olx.source.TileWMSOptions} */ ({
      url: 'http://172.16.1.58:8080/geoserver/KBJNL/gwc/service/wms',
      params: {
        'LAYERS': layerName,
        'TILED': true
      },
      serverType: 'geoserver'
    }))
  });

  map.addLayer(tl);
}


function removeTOCLayer(ss) {
  map.removeLayer(ss);
}

1 个答案:

答案 0 :(得分:4)

您正在混合图层名称和图层参考。您必须按名称保留图层索引。试试这个:

heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.4755
== 20150512123847 ChangePricetoDecimal: migrating =============================
-- change_column(:products, :price, :decimal)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DatatypeMismatch: ERROR:  column "price" cannot be cast automatically to type numeric
HINT:  Specify a USING expression to perform the conversion.