- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想向我的瓦片 map 添加功能,当我尝试使用时出现问题
ol.source.TileWMS
错误信息是:
TypeError: a.addEventListener is not a function
但是它可以与
ol.source.OSM
我的代码:
var projection = new ol.proj.Projection({
code: 'EPSG:32719',
extent: [441867.78, 1116915.04, 833978.56, 10000000.00]
});
var extent = [576631.5686027373,8119272.722829757,655823.9357532839,8286730.359291008];
var wmsSource = new ol.source.TileWMS({
url: 'http://192.168.5.94:8080/geoserver/wms',
params: {'LAYERS': 'layer'},
ratio: 1,
serverType: 'geoserver'
});
var wmsLayers = [
new ol.layer.Tile({
extent: extent,
source: wmsSource
})
];
var raster = new ol.layer.Tile({
source: new ol.source.OSM()
});
var source = new ol.source.Vector({wrapX: false});
var vector = new ol.layer.Vector({
source: source
});
var view = new ol.View({
projection: projection,
center: [593169.72792, 8174979.55243],
//center: ol.proj.fromLonLat([-16.5088, -68.1388], projection),
extent: extent,
zoom: 12
});
var map = new ol.Map({
controls: ol.control.defaults().extend([
new ol.control.ScaleLine()
]),
layers: [wmsLayers, vector],
target: 'map',
view: view
});
var draw; // global so we can remove it later
function addInteraction(){
draw = new ol.interaction.Draw({
source: source,
type: 'Point'
});
map.addInteraction(draw);
}
map.on('singleclick', function(evt) {
var coordinate = map.getEventCoordinate(evt.originalEvent);
console.log(coordinate);
document.getElementById('latitud').value = coordinate[0];
document.getElementById('longitud').value = coordinate[1];
addInteraction();
});
addInteraction();
只需更改此行即可更改我的图层,当我使用 OSM 时,一切正常...但是当我使用 TileWMS 时出现错误
layers: [wmsLayers, vector],
与TileWMS和Vector源有冲突吗?
最佳答案
ol.Map.layers 需要一个图层数组 - 数组中的第一个对象是一个数组。
试试这个:
var wmsLayer = new ol.layer.Tile({
extent: extent,
source: wmsSource
});
var map = new ol.Map({
layers: [wmsLayer, vector],
target: 'map',
view: view
});
关于javascript - Openlayers源码tileWMS?类型错误 : a. addEventListener 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45305429/
我有一个来自地理服务器的 TileWMS 图层。我试图用传单(正确地)展示它。唯一的问题是 THE WHOLE WORLD map 似乎围绕着我的 TileWMS 层。所以我在我的层周围得到了一个完整
我正在使用 OpenLayers/Geoserver 开发一个真实状态的软件,到目前为止我所做的是有一个带有 WMS 图层的 map ,我可以在其中显示特定条件下的绘图。 由于函数 getFeatur
我正在使用开放层 3,我正在使用此代码来显示 map : wmsSource = new ol.source.TileWMS({ url: 'http://demo.boundl
我正在使用 openlayers 3 以及来自 mapbox 或 openstreetmap 的图层,我需要在其上绘制一些圆圈。 我可以用投影 EPSG:4326 的 View 打印圆圈,但我没有 m
我是一名优秀的程序员,十分优秀!