How can I get the popup value to change when I click on another feature, without clic

المشرف العام

Administrator
طاقم الإدارة
I'm working with openLayers 3, which is new to me, and I've been able to add a popup to my map that comes up when you click on a feature in a vector layer. The trouble is the popup content does not update when you click on another feature; you need to click on an area where there isn't a feature to close it, then click on another feature for the popup content to refresh. I'd like for the popup content to update when you click on a new feature, without having to click on an area where there is not feature first. Is there a way I can do this? Here is the code for the popup that I am using:

map.on('click', function(evt) { var feature = map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) { return feature; }); if (feature) { popup.setPosition(evt.coordinate); $(element).popover({ 'placement': 'top', 'html': true, 'content': 'Parcel No:
'+ feature.get('parcel')+'
'+ 'Owner:
'+ feature.get('primowner') }); $(element).popover('show'); } else { $(element).popover('destroy'); }});

أكثر...
 
أعلى