deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

Way to interact with non-deck.gl mapbox layer?

Open Harrisandwich opened this issue 8 years ago • 2 comments

Sorry for ditching the template. I wasn't sure how to apply this question to it.

I understand this is probably by design, but I have a special case where I would like to be able to get around the Deckgl component that is wrapped around the ReactMapGL component in order to access click events on the mapbox map.

Currently having color update issues with the DeckGL experimental TileLayer, so I was going to go back to the old mapbox vector layer. The layer adds fine using map.addLayer(layer) but all interactivity to that layer is being blocked by either deck.gl or react-map-gl.

Is there any way I can interact with this vector layer? Perhaps even using deck or react-map-gl?

Harrisandwich avatar Nov 06 '18 13:11 Harrisandwich

It's not clear from your description how you are accessing the click event. Mapbox's native event handling is disabled because it interferes with the deck.gl viewport interaction. You can however do this:

<DeckGL ...
  onLayerClick={(info, allInfos, event) => {
    const mapboxFeatures = this.refs.map.queryRenderedFeatures([evt.offsetX, evt.offsetY]);
    console.log(mapboxFeatures);
  }}>
  <StaticMap ref="map" />
</DeckGL>

See documentations of onLayerClick and queryRenderedFeatures.

Pessimistress avatar Nov 06 '18 18:11 Pessimistress

@Harrisandwich have you ever been load tile layer published by youself. I tried load a building layer published by geoserver. #3329, could you help me have a look.

HeiYanjing avatar Jul 17 '19 10:07 HeiYanjing