'Unable to listen to onPress or onSelect event on custom Marker component in react-native-maps
I am using react-native-maps and trying to show a custom component instead of a pin. what have I tried so far?
It wrapped the component inside Callout, it works but again it shows the pin and my custom component when it is on focus.
Tried onSelec, onPress & onTouchEnd on Marker
tried toggling the stopPropagation Prop on Marker.
Tried all possible solutions on stack overflow and elsewhere
** Side note, I am testing my app only on IOS **
Here is the code -
<MapView
liteMode
mapType='standard'
// @ts-ignore
userInterfaceStyle='light'
showsUserLocation
initialRegion={{
latitude: 43.82188123552105,
longitude: -79.33542533781197,
latitudeDelta: 0.01,
longitudeDelta: 0.01
}}
region={recenter}
followsUserLocation={false}
userLocationPriority='high'
minZoomLevel={2}
showsMyLocationButton
showsPointsOfInterest
showsCompass
showsTraffic
showsBuildings
showsIndoors
loadingEnabled
// onMarkerSelect={() => alert('swsaw')}
zoomControlEnabled={true}
// onMarkerPress={() => alert('sa')}
style={tw.style('w-full h-full')}
>
{
arr.map(item => (
<Marker key={`${item.id}`}
identifier={'JASSA-' + i}
pointerEvents={'auto'}
stopPropagation={true}
onTouchEnd={(e) => { e.stopPropagation(); alert('SASA') }}
coordinate={{latitude: loc.lat, longitude: loc.lng}}>
<MyCustomComponent />
</Marker>
))
}
</MapView>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
