component popup needs to be clicked very precise in order to pop up

Created on 17 October 2016, about 8 years ago
Updated 4 November 2023, about 1 year ago

I added the component popup to one map using the default style. I find it rather difficult to get a popup open on map size 900 to 400 px and about 10 markers on it. Sometimes I have to click 2-4 times till something opens. And when it opens the point is always relative to the clicked position within the marker.

From my point the clickable point is too precise, too small. Is there any configuration that can help avoiding having a very small clickable point?

💬 Support request
Status

Fixed

Version

3.0

Component

OL Layers

Created by

🇫🇮Finland Nchase

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇸🇰Slovakia sano

    I am setting the Hit Tolerance to 200 and get the same result as when is it set to 0. Maybe something has changed between releases 7.x-3.2 and 7.x-3.3 that I am using?

  • 🇸🇰Slovakia sano

    It looks like the Hit tolerance functionality was removed in this commit.

    I made the following change* to make this work (in the src/Plugin/Component/Popup/js/popup.js file). I replaced the old bit of code with the new one - see below.

    The old code:

        map.on('click', function(evt) {
    
          if ('getFeaturesAtPixel' in map) {
            //  Introduced in v4.3.0 - new map.getFeaturesAtPixel() method.
            var features = map.getFeaturesAtPixel(evt.pixel);
          } else {
            //  Replaced in v4.3.0 - forEachFeatureAtPixel() method replaced.
            features = [];        
            map.forEachFeatureAtPixel(evt.pixel, function(feature) {
              features.push(feature);
            });
          }
    
          var feature = undefined;
    
          if (features && features.length > 0) {
            for (item of features) {
              feature = item;
            }
          }
        });
    

    The new code:

    	map.on('click', function(evt) {
    	  var hitTolerance = data.opt.hitTolerance || 0;
    
    	  if ('getFeaturesAtPixel' in map) {
    		// Introduced in v4.3.0 - new map.getFeaturesAtPixel() method with hitTolerance.
    		var features = map.getFeaturesAtPixel(evt.pixel, { hitTolerance: hitTolerance });
    	  } else {
    		// Replaced in v4.3.0 - forEachFeatureAtPixel() method replaced.
    		features = [];
    		map.forEachFeatureAtPixel(evt.pixel, function(feature) {
    		  features.push(feature);
    		});
    	  }
    
    	  var feature = undefined;
    
    	  if (features && features.length > 0) {
    		for (item of features) {
    		  feature = item;
    		}
    	  }
    	});
    

    * thank you ChatGPT :-)

  • @sano opened merge request.
Production build 0.71.5 2024