使用openlays6.2.1,我试图从xyz源(如色彩操纵示例)中更改瓷砖的像素颜色,
我首先定义了一个XYZ源:
const xyz = new XYZ({
url: 'https://mbenzekri.github.io/frcommunes/fr/communes/{z}/{x}/{y}.png',
maxZoom: 12,
minZoom: 5
})然后是一个RasterSource来操纵颜色
const rastersource= new Raster({
sources: [ xyz ],
operation: function (pixels, data) {
pixels[0] = pixels[0]
pixels[1] = pixels[1]
pixels[2] = pixels[2]
}
})然后是一个ImageLayer:
const imagelayer = new ImageLayer({
source: rastersource
})在OSM层对象上将此层添加到映射中,在呈现时出现消息失败:
TileLayer.js:160 Uncaught TypeError: tileSource.getTileGridForProjection is not a function
at CanvasTileLayerRenderer.renderFrame (TileLayer.js:160)
at TileLayer.Layer.render (Layer.js:216)
at CompositeMapRenderer.renderFrame (Composite.js:112)
at Map.PluggableMap.renderFrame_ (PluggableMap.js:1265)
at Map.<anonymous> (PluggableMap.js:186)用相同的xyz源替换一个简单的TileLayer可以很好地工作(源代码行index.js:37)。
const tilelayer = new TileLayer({
source: xyz
})我是不是做错了什么,错过了一些配置?
预先感谢您的帮助或关心
完整代码为这里 (简单示例50行)
没有bug的版本在github页面上是可测试的。
发布于 2020-02-28 17:54:04
你的进口是错的。
import ImageLayer from 'ol/layer/Tile';应该是
import ImageLayer from 'ol/layer/Image';https://stackoverflow.com/questions/60456611
复制相似问题