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

how to select feature in WebGLVectorTileLayer #15255

Open
younggis opened this issue Oct 22, 2023 · 7 comments
Open

how to select feature in WebGLVectorTileLayer #15255

younggis opened this issue Oct 22, 2023 · 7 comments

Comments

@younggis
Copy link

younggis commented Oct 22, 2023

I created a layer as this:

      class WebGLVectorTileLayer extends VectorTileLayer {
        createRenderer() {
          return new WebGLVectorTileLayerRenderer(this, {
            style: {
              fill: {
                fragment: result.builder.getFillFragmentShader(),
                vertex: result.builder.getFillVertexShader(),
              },
              stroke: {
                fragment: result.builder.getStrokeFragmentShader(),
                vertex: result.builder.getStrokeVertexShader(),
              },
              symbol: {
                fragment: result.builder.getSymbolFragmentShader(),
                vertex: result.builder.getSymbolVertexShader(),
              },
              attributes: {
                fillColor: {
                  size: 2,
                  callback: (feature) => {
                    return packColor([21, 255, 18, 1])
                  },
                },
                strokeColor: {
                  size: 2,
                  callback: (feature) => {
                    return packColor([255, 255, 255, 1])
                  },
                },
                strokeWidth: {
                  size: 1,
                  callback: (feature) => {
                    return 1
                  },
                },
              },
            },
          })
        }
      }
      let layer = new WebGLVectorTileLayer({
        source: new VectorTileSource({
          attributions: [],
          format: new MVT(),
          url: API_URL + 'mapManage/GetRasterMVT?z={z}&x={x}&y={y}',
          minZoom: MIN_ZOOM,
          maxZoom: MAX_ZOOM,
        }),
      })

now, how to select the feature in this layer?
please
thank you

@mike-000
Copy link
Contributor

The Vector Tile layer example https://openlayers.org/en/latest/examples/vector-tile-selection.html uses feature id, so a fix for #15251 would be needed before something similar can be attempted in WebGL.

@mike-000
Copy link
Contributor

It seems this is still not possible. Although #15120 also updated WebGLVectorTileLayerRenderer to enable the VectorStyleRenderer to hit detect by default map.forEachFeatureAtPixel returns no hits and layer.getFeatures is not supported.

@jahow
Copy link
Contributor

jahow commented Oct 28, 2023

Hit detection on vector tile layers rendered using WebGL is currently being worked by @gberaudo on and a PR is likely to come in the near future.

@IdenPin
Copy link

IdenPin commented Nov 1, 2023

We look forward to hearing from you soon. @jahow

@vitalus
Copy link

vitalus commented Nov 26, 2023

So, my case is (not vector tiles, but a Vector Source with features)

  1. useGeographic()
  2. WebGL layer with feature source and preloaded features in EPSG:4326
  3. Default Select tool working with WebGL layer..

It seems that internally some "math" is not yet correctly working.

image

The value of "ref" variable has nothing related to real "ref" as keys in batch_ data stucture of WebGL renderer... (looks like it should be 1,2,3... N

Source code is a bit of magic at the moment for me in WebGL renderer, so just inconsistency of calculated "ref" value is obvious, may be it helps.

Codebase is OL 8.2.0

@jahow
Copy link
Contributor

jahow commented Nov 26, 2023

@vitalus thanks for reporting, this problem has most likely been fixed by #15340; unfortunately, this hasn't made it to 8.2.0. Could you please let us know if the issue persists when using the ol@dev latest package? Thanks!

@vitalus
Copy link

vitalus commented Dec 3, 2023

in version 9.0.0-dev.1701358929517 selection is working normally, seems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants