React-native-mapbox-gl: MapView onPress event not firing @ 6.1.1 & [email protected]

Created on 8 May 2018  Â·  32Comments  Â·  Source: nitaliano/react-native-mapbox-gl

Hi,

I'm using [email protected] and [email protected] in Genymotion Android 7.1.

It seems that onPress event of MapView is not getting fired. Nothing happens when I click on the map but the map is otherwise working fine.

I think this started to happen after updating react-native and react-native-mapbox-gl to latest versions.

Is anyone else experiencing this bug?

<MapboxGL.MapView
          logoEnabled={false}
          ref={(map) => {this.mapRef = map}}
          styleURL={this.mapStyleURI}
          compassEnabled={false}
          zoomLevel={2}
          centerCoordinate={[southWestLatLng.longitude, southWestLatLng.latitude]}
          style={styles.mapView}
          attributionEnabled={false}
          onRegionDidChange={this.onMapRegionChange}
          onPress={() => console.log('TEST')}>

          <MapboxGL.ShapeSource id='markerSource' shape={markerCoordinates}>
            <MapboxGL.SymbolLayer
              id='markerSymbols'
              style={mapStyles.defaultMarker} />
          </MapboxGL.ShapeSource>

</MapboxGL.MapView>

Most helpful comment

@schabaani You could get the 6.1.2 master branch like this:

"@mapbox/react-native-mapbox-gl": "git+https://github.com/mapbox/react-native-mapbox-gl#release/6.1.2“

All 32 comments

Seems to be working on a production build in real device with Android 7.

I'm having a similar issue (debug mode on real android 7.0 device). onPress, onLongPress, onRegionDidChange events (these are the ones tested by me) stopped working after updating to the latest version of react-native.

What i found so far: When freshly installed my app in debug mode, events are working. As soon as i attach the debugger, the events stop working. They will work again, if you detach the debugger, kill and restart your app.

The same problem with the ShapeSource onPress

Had same issue with 6.1.2-beta2 / Android 7 / react-native 0.55 (expo) all onPress events failed to trigger. Downgrading to at least 6.0.3 fixed it.

I'm not able to reproduce this issue at all, would someone be able to provide steps and if you're using the debugger or not? We just shipped an app with 6.1.2-beta2 and all the presses are working.

I'm finding that on a fresh compile react-native run-android, the onPress events are going through, but after a JS reload, neither MapView.onWillStartLoadingMap nor ShapeSource.onPress get called anymore.

Seems to be Android only, RN 0.55.4, Mapbox 6.1.2-beta2

great, thanks for the extra steps @MarkPolivchuk will take a look

good news is I can reproduce this now

Did anyone solve this? I have the same issue. I've downgraded maps to 6.0.3 like janimaiin adviced but event's don't work anymore. Furthermore I noticed that all events are getting fired once when maps are rendering and after this no events are fired. (I,m using onLongPress, onPress, onRegionDidChange)
"@mapbox/react-native-mapbox-gl": "6.0.3",
"react": "16.3.1",
"react-native": "0.55.4",
Platform: Android 8.0

This is already fixed on master by this PR https://github.com/mapbox/react-native-mapbox-gl/pull/1214 I will publish another npm package soon, for now you can point to master

@nitaliano I'm actually using the master branch but the ShapeSource onPress not solved yet.

Looks like the fix is only in release/6.1.2 branch and not merged to master. Did a very quick test with that branch and from there it seems to work fine.

@janimaiin I’ve get the 6.1.2 branch like this:

"@mapbox/react-native-mapbox-gl": "git+https://github.com/mapbox/react-native-mapbox-gl#release/6.1.2“

Yes, that looks the same path as I have.

@janimaiin so you have aproblem yet with this?

Same problem( 6.1.2-beta2 )

@schabaani You could get the 6.1.2 master branch like this:

"@mapbox/react-native-mapbox-gl": "git+https://github.com/mapbox/react-native-mapbox-gl#release/6.1.2“

Wow, thanks. After a looiot of hours trying to figure out what I've done wrong, downgrading to 6.1.2 solved the issue for me. Thanks!
What happened in the latest release? Is there a bugfix on it's way?
https://github.com/mapbox/react-native-mapbox-gl/issues/1237

I'm finding that on a fresh compile react-native run-android, the onPress events are going through, but after a JS reload, neither MapView.onWillStartLoadingMap nor ShapeSource.onPress get called anymore.

Seems to be Android only, RN 0.55.4, Mapbox 6.1.2-beta2

@Schabaani You could get the 6.1.2 master branch like this:

"@mapbox/react-native-mapbox-gl": "git+https://github.com/mapbox/react-native-mapbox-gl#release/6.1.2“

Hi. Not working.
RN 0.57.1
How can I fix it?

I also downgraded to 6.1.2 and its working.

We downgraded to 6.1.2 from 6.1.3 and its still not working.

I don't have any events working on iOS. latest RN version as well, that's weird

I am facing same issue with onRegionDidChange. I am using below listed version in app. Its working fine with Android device but not fire with iOS devices.

"@mapbox/react-native-mapbox-gl": "6.1.2"
"react-native": "0.55.4"

Can anyone please help how to get working of this event with iOS too.

I guess this is addressed in the 7.0 release @nitaliano / @zugaldia?

I'm having the same issue (tested on 6.1.2 and 6.1.3). Hard-closing and restarting the app in the emulator fixes it until the next hot reload.

I've had the same issue with the master branch and it seems that this is due to expo not implementing ReactApplication.
I changed following method in the AbstractEventEmitter:
private RCTEventEmitter getEventEmitter() { return RCTAppContext.getJSModule(RCTEventEmitter.class); }
and added a new method which is called when a reload occurs:
@Override protected void addEventEmitters(ThemedReactContext context, T view) { mRCTAppContext = context; }
I'm new to React-Native development, so I don't know how well this fix is, but it works for me.
I've tested this on my expo application and a fresh react-native project with just mapbox, and in both cases the events fire after reload.

1508

@nitaliano friendly ping - any update on this?

@jliebrand Have you tried it with my update?

Still getting this after reloading in debug.

Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([235,"rct.mapbox.map.change",{"payload":{},"type":"didfinishrenderingframe"}])

This is what logcat starts spamming after reload, different lifecycle functions (didfinish, willstart etc)

"react": "^16.6.3",
"react-native": "^0.58.6",
"@mapbox/react-native-mapbox-gl": "^6.1.3",

@Anttijva, you’ll need to install from master instead of NPM. The latest update haven’t been published as we’re in the middle of transferring the NPM package.

@kristfal I think that fixed it, android performance is significantly better now. Thank you guys for keeping this library up!

Glad to hear. Sorry for the state of things right now. I hope we can sort out publishing and ownership as soon as possible.

Closing as issue seems resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

madroneropaulo picture madroneropaulo  Â·  4Comments

digitaldavenyc picture digitaldavenyc  Â·  4Comments

alexisohayon picture alexisohayon  Â·  4Comments

Maxence-Machu picture Maxence-Machu  Â·  3Comments

lernerbot picture lernerbot  Â·  3Comments