Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forEachFeatureAtPixel layerFilter not excute in right way #537

Closed
erDuo10 opened this issue Jul 17, 2023 · 3 comments
Closed

forEachFeatureAtPixel layerFilter not excute in right way #537

erDuo10 opened this issue Jul 17, 2023 · 3 comments
Labels

Comments

@erDuo10
Copy link

erDuo10 commented Jul 17, 2023

image

onMapPointerMove(e) {
  let hitFeature = this.$refs.map.$map.forEachFeatureAtPixel(
    e.pixel,
    this.handleDemanderFeatureClick,
    { layerFilter: function(layer) {
        const id = layer.get("id");
        return id != undefined && id.startsWith('wells-status');
      }
    }
  )

  console.error('onMapPointerMove hitFeature:', hitFeature);
},
 handleDemanderFeatureClick(feature, layer ){
   console.error('handleDemanderFeatureClick feature:', feature);
   console.error('handleDemanderFeatureClick layer:', layer);

   return feature;
 },

as the code show, layerFilter do not implement filter use, the filter code could not trigger the callbak method handleDemanderFeatureClick.

after delete the filter, the onMapPointerMove trigger many a time

@ghettovoice
Copy link
Owner

Hello @erDuo10 ,

You should check layer id is correct, and is it "managed"(not added as overlay) layer, is it vector layer and etc.
There is extended documentation https://openlayers.org/en/v6.15.1/apidoc/module-ol_Map-Map.html#forEachFeatureAtPixel, when call though this.$refs.map.$map.forEachFeatureAtPixel.
There is also a demo https://jsfiddle.net/ghettovoice/Ln9qr135/460/

@erDuo10
Copy link
Author

erDuo10 commented Jul 18, 2023

Thank you! That helps a lot.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Aug 17, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants