-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Markers does not update after props change on Android #1611
Comments
There's a solution? |
+1, same here!! |
Android seems to be relying only on the key to change in order to update the custom marker. When you re-render try changing your key. This works for me:
|
@chrismcleod This works, not exactly how i expected but works, thanks 👍 This is the code.
When i click on the market it re-render how i expected but then it hides the infowindow. |
@chrismcleod livesaver! |
Nice bug :( let's hack everything a little more to find a workaround.
I ran into the same issue. Solved this way: <MapView.Marker
coordinate={ position }
key={`${x._id}${isSelected(x._id) ? '-selected' : ''}`} // <-- updates only selected (and deselected) marker
identifier={x._id} // <-- we need this to invoke showCallout
ref={(ref) => this._markers[x._id] = ref} // <-- store ref
onPress={this._onPressMarker}
> onPressMarker(e) {
setTimeout(() => // sadly, we need timeout to make this command run in next cycle, after map updates.
this._markers[e.nativeEvent.id].showCallout()
, 0);
} |
* master: (168 commits) Adding overlaying components details (react-native-maps#2425) docs: pin color limitations for android (react-native-maps#2429) Revert "Added MBTiles support for iOS and Android (react-native-maps#2208)" (react-native-maps#2387) Added MBTiles support for iOS and Android (react-native-maps#2208) Fix disabling the toolbar and my location button (react-native-maps#2317) Fixes warnings about self (react-native-maps#2341) Android: Fix lineCap of Polyline (react-native-maps#2375) Update installation.md (react-native-maps#2381) update doc (react-native-maps#2363) zIndex doesn't work when the map moves in iOS 11 (react-native-maps#2359) Fix readme formatting (react-native-maps#2358) add support for calloutAnchor with GoogleMaps on iOS; fixes react-native-maps#1852 (react-native-maps#2351) Added animateToNavigation method to MapView (react-native-maps#2049) Add react-native@^0.55 to peerDependencies (react-native-maps#2332) Fix custom marker updates on android react-native-maps#1611 react-native-maps#2048 [iOS] Prefix or eliminate globals in AIRMapMarker (react-native-maps#2306) Fix CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF warnings (react-native-maps#2154) Fix for compile error (react-native-maps#2215). (react-native-maps#2232) Make tiles display at the same physical size regardless of pixel dens… (react-native-maps#2248) Added support of lineDashPattern polyline prop to iOS Google Maps (react-native-maps#2243) ... # Conflicts: # lib/components/MapMarker.js
Hi there. Any stable solution for this?
But I still got issue that markers don't show on first load. |
@khuongdv I have a similar problem with pins not rendering on the first load, did you found any solutions regarding this? |
To me, not setting |
Do you mean the property called |
Ok, probably my suggestion isn't worth anything, I was referring to https://github.com/react-community/react-native-maps/blob/master/docs/mapview.md where |
I used the Date.now() as suggested by @chrismcleod in key={ |
…ive-maps#2048 Android: [react-native-maps#2320](react-native-maps#2320) Fixed custom marker updates on Android
@DerekPark i used similar solution. Uniq id + isActive state |
Date.now() cause a huge performance loss. It re-creates the marker instead of re-render every time. |
use this in the marker |
For android it does not work |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@chrismcleod you're a hero, man!! |
Strangely this issue is happening to me on ios (google maps) but not on android. Changing the key did fix it for me though. |
…dates Fix custom marker updates on android react-native-maps#1611 react-native-maps#2048
Hi everyone,
I'm having an issue on Android where the custom marker does not update after its props have change.
When i press the marker, its marked like selected and vice versa. Then its backgroundColor changes to identify that it has beed selected or not. This is working fine on iOS - Mapkit but on Android - Google Map does not update the change.
On Android - Google Map. Does not update the change.
On iOS - Mapkit works perfectly. This is the expected behavior.
Here is my code.
State and method
MapView Component
Custom Marker Component
Helper function
Tell me if you need more details.
Thanks.
The text was updated successfully, but these errors were encountered: