Geographic Information Systems Asked by Dany on October 4, 2021
I’m using GetInfo to view the cover information and my problem using this command is: The information displayed is not from the cover seen on the map, but from the first cover inserted in the code. I always see information from the cover Layer_21_11_19 even if I’m seeing and clicking on the cover Layer_12_12_19.
Please, does anyone know how to show the information only on the cover I’m seeing and clicking?
map.on('click', function getInfo(e){
if(e.name !== 'Click'){
e.name = "Click";
map.addEventListener('click', (evt) => {
const projection = map.getView().getProjection().getCode()
const isGlobal = map.getView().getProjection().isGlobal()
const viewResolution = view.getResolution();
const wmsSource = new ol.source.ImageWMS({
url: 'http://localhost:8080/geoserver/WORK/wms',
params: {'LAYERS': [
'Layer_21_11_19',
'Layer_23_11_19',
'Layer_12_12_19'
]} });
url = wmsSource.getFeatureInfoUrl(
evt.coordinate,
viewResolution,
'EPSG:4326',
{'INFO_FORMAT': 'text/html','FEATURE_COUNT': 1}
);
if(url){
const closer2 = document.getElementById('popup-closer2');
const content2 = document.getElementById('popup-content2');
const xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = () => {
if (xhttp.readyState === 4 && xhttp.status === 200) {
content2.innerHTML = xhttp.responseText;
thisoverlay2.setPosition(evt.coordinate)
}};
xhttp.open("GET", url, true);
xhttp.send();
} else if (e.name === 'Click'){
e.name = "Unclick";
map.removeEventListener('click');
} }) } } })
You need to either specify just the layer you are interested in in the LAYERS
parameter or increase the number of features returned by increasing FEATURE_COUNT
.
Answered by Ian Turton on October 4, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP