maps: [Bug]: On Android, onLongPress function is working only once(initial render)
Mapbox Implementation
Mapbox
Mapbox Version
10.1.32
React Native Version
0.74.5
Platform
Android
@rnmapbox/maps version
10.0.0-beta.32
Standalone component to reproduce
import React from 'react';
import {
MapView,
ShapeSource,
LineLayer,
Camera,
} from '@rnmapbox/maps';
const aLine = {
type: 'LineString',
coordinates: [
[-74.00597, 40.71427],
[-74.00697, 40.71527],
],
};
class BugReportExample extends React.Component {
render() {
return (
<MapView style={{flex: 1}} onLongPress={() => console.log("long press")}>
<Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
<ShapeSource id="idStreetLayer" shape={aLine}>
<LineLayer id="idStreetLayer" />
</ShapeSource>
</MapView>
);
}
}
Observed behavior and steps to reproduce
onLongPress is triggered only once (during the initial render) on Android, but works as expected on iOS.
Expected behavior
onLongPress should be triggered whenever the user performs a long press on the map.
Notes / preliminary analysis
No response
Additional links and references
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 14
- Comments: 21 (3 by maintainers)
Commits related to this issue
- build(Packages): Minor and patch updates (Except @rnmapbox/maps as long press still an issue https://github.com/rnmapbox/maps/issues/3715) — committed to StraboSpot/StraboField by jessicagood 2 years ago
- issue #3715 — committed to bartsolutions/maps by gongdao123 2 years ago
@deathook007 Here’s my complete workaround by locally patching the previously suggested version:
My rnmapbox version at the moment is:
"@rnmapbox/maps": "10.1.37",(this is important for the patch definition)npm i patch-packagepatches/@rnmapbox+maps+10.1.37.patchwith the following content:`npx patch-packageto patch the rnmapbox package."eas-build-post-install": "patch-package"Of course, this does not solve the problem, just downgrades the mapbox version to one that works, while keeping up with other fixes in this repo. At some point downgrading the version will break the library, but for now it works.
Hope this helps.
If you change def defaultMapboxMapsVersion = “10.18.0” in build.gradle of the this lib then its working