Openlayers3 WMS GetFeatureInfo request only returns info for one feature

المشرف العام

Administrator
طاقم الإدارة
I have a point dataset in an Openlayers 3 map. The aim is to be able to click each point and get the information about that point displayed. The code below works just fine, it loads all the layers up and when I click a point, it retrieves some information. However it will only return information for one point, no matter where I click on the map. Can anyone see where I have gone wrong here?

var layers = [ new ol.layer.Tile({ source: new ol.source.MapQuest({layer: 'sat'}) }), new ol.layer.Image({ extent: [16935988.2390421, -3393028.96482803, 17102996.5023459, -3207079.63356002], source: new ol.source.ImageWMS({ url: 'http://geonct.com:80/geoserver/NCTPROP/wms', params: {'LAYERS': 'NCTPROP:corr'}, serverType: 'geoserver' }) }), new ol.layer.Image({ extent: [16935988.2390421, -3393028.96482803, 17102996.5023459, -3207079.63356002], source: new ol.source.ImageWMS({ url: 'http://geonct.com:80/geoserver/NCTPROP/wms', params: {'LAYERS': 'NCTPROP:br_web'}, serverType: 'geoserver' }) }), new ol.layer.Tile({ source: new ol.source.TileWMS({ url: 'http://geonct.com:80/geoserver/NCTPROP/wms', params: {'LAYERS': 'NCTPROP:br_point'}, serverType: 'geoserver' }) })];function loadMap(){var map = new ol.Map({ layers: layers, target: 'map', view: new ol.View({ center: [17031695, -3310901], zoom: 9 })});var view = new ol.View({ center: [0, 0], zoom: 1});map.on('singleclick', function(evt) { document.getElementById('info').innerHTML = ''; var viewResolution = /** @type {number} */ (view.getResolution()); var url = layers[3].getSource().getGetFeatureInfoUrl( evt.coordinate, viewResolution, 'EPSG:3857', {'INFO_FORMAT': 'text/html'}); if (url) { document.getElementById('info').innerHTML = ''; }});};function layerSwap(evt){ layers[evt.value].setVisible(evt.checked);}

أكثر...
 
أعلى