Skip to content

Can streetscape.gl listen to mapbox's own event #370

@Questionboy

Description

@Questionboy

hi,
I make an underground parking map by geoserver. And I load the map through change the MAP_STYLE. I want to click the map and get the parking space information from map.
I see that streetscape.gl use the react-map-gl to load map. In module of components/log-viewer/core-3d-viewer.js, the load event of StaticMap can get the map instance of mapbox. So I register mapbox's own event in here. Just like this:

_onMapLoad = evt => {
const map = evt.target;
map.on('click', function (e) {
console.log("mapbox click");
});
map.on('click', 'newpark', function (e) {
console.log("mapbox layer click");
});
this.props.onMapLoad(map);
};

Howerver It doesn't work!
Is there any way to listen to mapbox's own event in streetscape.gl

Activity

twojtasz

twojtasz commented on Aug 12, 2019

@twojtasz
Contributor

@Pessimistress any suggestions?

Pessimistress

Pessimistress commented on Aug 12, 2019

@Pessimistress
Contributor

We disable pointer interaction on the map. You can do something like

onClick={evt => {
  this._map.queryRenderedFeatures(...);
}}
_onMapLoad={evt => {
  this._map = evt.target;
}}
Questionboy

Questionboy commented on Aug 13, 2019

@Questionboy
Author

Thank you for your reply. As you say, I change the StaticMap to InteractiveMap and try to add the onClick event in InteractiveMap. However, I cann't get any return from onClick event in InteractiveMap. It must be intercept by the click event in deck.gl.

JianXinyu

JianXinyu commented on Dec 23, 2021

@JianXinyu
queryRenderedFeatures

Hi, did you solve this in the end? I have the same problems now. Thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @twojtasz@Pessimistress@Questionboy@JianXinyu

        Issue actions

          Can streetscape.gl listen to mapbox's own event · Issue #370 · aurora-opensource/streetscape.gl