我正在尝试在示例popupinfo的帮助下使用 openlayers 3 javascript获取地图点击上的功能信息
var mmi = new ol.layer.Tile({
source: new ol.source.OSM()
});
var one = new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://localhost:8080/geoserver/wms',
params: {'LAYERS': 'cite:abc'},
format: new ol.format.GeoJSON(),
ratio: 1,
serverType: 'geoserver'
})
});
var map = new ol.Map({
layers: [mmi,one],
target: 'map',
view: new ol.View({
center: ol.proj.fromLonLat([73.6608, 29.8820]),
zoom: 8
})
});
map.on('click', function(evt) {
var feature = map.forEachFeatureAtPixel(evt.pixel, function(feature, one)
{
return feature;
})
});
<link href="https://openlayers.org/en/v4.6.4/css/ol.css" rel="stylesheet"/>
<script src="https://openlayers.org/en/v4.6.4/build/ol-debug.js"></script>
<div id="map" class="map"></div>
<div id="map" class="information"></div>
在我的地图点击事件中,特征值什么都不是。如何在点击它时获得功能的价值。