Making get feature request to forget between clicks in OpenLayers 3

المشرف العام

Administrator
طاقم الإدارة
I currently have a map with projects on it that when you click on it, it returns the information of said project using the code below.

The issue i'm having is that every so often it will duplicate the responses it is returning. It's almost as though it's remembering that it's been previously clicked on and then adding another response on top of it. How can I make it stop doing this?

function projectName(browserEvent) { var coordinate = browserEvent.coordinate; var pixel = map.getPixelFromCoordinate(coordinate); var el = document.getElementById('projectNumber'); el.innerHTML = ''; map.forEachFeatureAtPixel(pixel, function(feature) { el.innerHTML += feature.get('Proj_Number') + '
'; return true; }); } map.on('pointerdown', projectName);

أكثر...
 
أعلى