Openlayers WMS - getGetFeatureInfoUrl 不是函数
Openlayers WMS - getGetFeatureInfoUrl is not a function
我有一个 wms 层,它在地图上显示正常,但是当我尝试在单击时从层中获取对象时,出现错误 getGetFeatureInfoUrl is not a function
var wmsSource = new TileWMS({
url: 'http://1.1.1.1:8080/geoserver/wms',
params: {'LAYERS': 'workspace:feature', 'TILED': true},
serverType: 'geoserver',
transition: 0,
});
var wmsLayer = new TileLayer({
source: wmsSource
})
var view = new View({
center: [0, 0],
zoom: 1,
});
if (checked) {
map.addLayer(wmsLayer);
}
else {
map.removeLayer(wmsLayer)
}
map.on('singleclick', function (evt) {
var viewResolution = /** @type {number} */ (view.getResolution());
var feature = wmsSource.getGetFeatureInfoUrl(
evt['coordinate'],
viewResolution,
'EPSG:3857',
{'INFO_FORMAT': 'text/html'}
);
if (feature) {
fetch(feature)
.then(function (response) { return response.text(); })
.then(function (info) {
console.log(info);
});
}
我能用它做什么?
解决方案是从图层中获取源代码:
map.on('singleclick', function (evt) {
var viewResolution = /** @type {number} */ (view.getResolution());
var feature = wmsLayer.getSource().getFeatureInfoUrl(
evt['coordinate'],
viewResolution,
'EPSG:3857',
{'INFO_FORMAT': 'text/html'}
);
if (feature) {
fetch(feature)
.then(function (response) { return response.text(); })
.then(function (info) {
console.log(info);
});
}
我有一个 wms 层,它在地图上显示正常,但是当我尝试在单击时从层中获取对象时,出现错误 getGetFeatureInfoUrl is not a function
var wmsSource = new TileWMS({
url: 'http://1.1.1.1:8080/geoserver/wms',
params: {'LAYERS': 'workspace:feature', 'TILED': true},
serverType: 'geoserver',
transition: 0,
});
var wmsLayer = new TileLayer({
source: wmsSource
})
var view = new View({
center: [0, 0],
zoom: 1,
});
if (checked) {
map.addLayer(wmsLayer);
}
else {
map.removeLayer(wmsLayer)
}
map.on('singleclick', function (evt) {
var viewResolution = /** @type {number} */ (view.getResolution());
var feature = wmsSource.getGetFeatureInfoUrl(
evt['coordinate'],
viewResolution,
'EPSG:3857',
{'INFO_FORMAT': 'text/html'}
);
if (feature) {
fetch(feature)
.then(function (response) { return response.text(); })
.then(function (info) {
console.log(info);
});
}
我能用它做什么?
解决方案是从图层中获取源代码:
map.on('singleclick', function (evt) {
var viewResolution = /** @type {number} */ (view.getResolution());
var feature = wmsLayer.getSource().getFeatureInfoUrl(
evt['coordinate'],
viewResolution,
'EPSG:3857',
{'INFO_FORMAT': 'text/html'}
);
if (feature) {
fetch(feature)
.then(function (response) { return response.text(); })
.then(function (info) {
console.log(info);
});
}