//Bind the mouse movement event to get the coordinate point
map.on('pointermove', function(evt) {
if (evt.dragging) {return;
}
displayFeatureInfo(evt);
});
//Inquire
var displayFeatureInfo = function (possibly) {
//Get the resource url generated by wms, fdLayer.getSource().getGetFeatureInfoUrl
var url = fdLayer.getSource().getGetFeatureInfoUrl(evt.coordinate, map.getView().getResolution(),'EPSG:4326', { 'INFO_FORMAT': 'application/json',
'FEATURE_COUNT': 1 });
//http request result data
$.ajax({url: url,
async: false,
dataType:'json',
success: function (data) {
if (data.features.length > 0) {
// Parse the geojson result
var feature = data.features[0];
//Get the properties you want in the wms service
var fdid = feature.properties.fdid;var fdno = feature.properties.fdno;
} else {
content.innerHTML = '';
overlay.setPosition(undefined);
}
}
})
};