Comments (9)
@lelandrichardson Is there anyway we can set the key
or ref
prop and have either those be available in the event callback?
from react-native-maps.
@christopherdro i don't think key
is available in the context of the child... and I'm not sure ref
is the best way to do it as refs come with a bit of overhead, and also wont be available in functional stateless components.
from react-native-maps.
So at the moment, it's not possible to know which marker triggered an onMarkerSelect
method for example ?
from react-native-maps.
@ghamaide You can use the onSelect
event on the marker directly, and you can also get the marker node by using the event.target
property.
from react-native-maps.
I'm a bit new to RN. How do I get info on the marker that triggered an onMarkerSelect method knowing the event.nativeEvent.target (which returns an integer, for example 514). I don't know what that integer represents in fact. This is what onMarkerSelect returns :
{ dispatchConfig: { registrationName: 'onSelect' },
dispatchMarker: '.r[1]{TOP_LEVEL}[0].0.0.3.$navigator.0.$nav0.0.$mapcontainer.$map.$465',
nativeEvent:
{ id: 'unknown',
coordinate: { longitude: 2.3575678, latitude: 48.8798646 },
target: 514,
action: 'marker-select' },
type: undefined,
target: undefined,
currentTarget: 514,
eventPhase: undefined,
bubbles: undefined,
cancelable: undefined,
timeStamp: 1455286645886,
defaultPrevented: undefined,
isTrusted: undefined,
isDefaultPrevented: [Function],
isPropagationStopped: [Function],
_dispatchListeners: [Function],
_dispatchIDs: '.r[1]{TOP_LEVEL}[0].0.0.3.$navigator.0.$nav0.0.$mapcontainer.$map.$465' }
from react-native-maps.
+1 for this. Im having a hard time tying this together.
My marker definition:
<MapView.Marker key={station.csmd.id} title= {'' + station.csmd.id} coordinate={ station.coords } onSelect= {this.onStationTap} image={require('../../assets/station.png')} />
As you can see from the image below, the only slight reference to the marker I have tapped is the last part of the dispatchMarker string in the event in the callback. currentTarget etc is some random number as far as I can see, not attached to the marker itself. Is this expected? Or am i doing something wrong here?
from react-native-maps.
You would actually think that a basic thing like being able to quickly see which marked was tapped on would be perhaps the most needed functionality of a map component. So I'm a bit surprise that this doesn't get more attention.
from react-native-maps.
The way I solved this for anyone interested was that I did a substring of the dispatchId prop to get the id (last digits behind $). Then using this id with "this.refs[id]". When initialising the markers i added the station as a parameter on the Marker.
from react-native-maps.
I’m closing this issue because it has been inactive for a while. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on for so long, then it seems no one has the time to implement this.
Please reopen if you still encounter this issue with the latest stable version.
Thank you!
from react-native-maps.
Related Issues (20)
- Custom marker start flicking without changing the state. HOT 14
- Task :react-native-maps:compileDebugJavaWithJavac FAILED HOT 1
- download map and save in pdf,png HOT 1
- Custom marker is croping from right to bottom. Only in IOS.
- Apple Privacy Manifest HOT 7
- Marker blinking issue HOT 5
- Markers are blinking on Android and Google Maps HOT 1
- CocoaPods could not find compatible versions for pod "react-native-google-maps" HOT 4
- Maptile works well on IOS , but it does not update on Android HOT 5
- Subview flickering on children index changes HOT 5
- Expo sdk50 cannot use it
- Marker don't display HOT 2
- Subview flickering on children index changes HOT 1
- [iOS] With Google Maps, zoomTapEnabled can't be modified and sometimes it's ignored. HOT 1
- 'onRegionChange' called long after changes has stopped HOT 1
- Invariant Violation: Event cannot be both direct and bubbling: topSelect HOT 1
- MapMarker onSelect does not fire with Google Maps on iOS HOT 1
- "googleMapId" not working on IOS HOT 2
- Error on startup on react-native 0.74 Bridgeless New Architecture HOT 18
- ANDROID DEVICE: addViewAt: failed to insert view [664] into parent [646] at index 0 The specified child already has a parent. You must call removeView() on the child's parent first. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-maps.