Expose tracksViewChange and icon property to improve some performance issues#1491
Expose tracksViewChange and icon property to improve some performance issues#1491PhamBaTho wants to merge 3 commits intoreact-native-maps:masterfrom PhamBaTho:master
Conversation
|
UPDATE: The We still need to have a better naming between |
| } | ||
|
|
||
| let icon; | ||
| if (this.props.icon) { |
There was a problem hiding this comment.
I would refactor this to ternary if statement :)
|
Thanks for this. Could you give a full example of use with the icon property? |
|
i discovered that if i use < image > the images are not being displayed on google maps (ios)... when i use the image property it works fine but i am not able to resize the images |
|
+1 would really like to see these optimizations in my app! |
|
@PhamBaTho - how do I add your changes to an existing project? I tried directly modifying the AirGoogleMaps in the project in xCode, but then I get a compile error: |
| | `identifier` | `String` | | An identifier used to reference this marker at a later date. | ||
| | `rotation` | `Float` | | A float number indicating marker's rotation angle, in degrees. | ||
| | `draggable` | `<null>` | | This is a non-value based prop. Adding this allows the marker to be draggable (re-positioned). | ||
| | `tracksViewChanges` | `Boolean` | | Controls whether the icon for this marker should be redrawn every frame. |
There was a problem hiding this comment.
Only applicable for iOS. Android don't have issues with that.
| * Using this property has an advantage over `image` in term of performance, battery usage... | ||
| * because it doesn't trigger tracksViewChanges. | ||
| * (tracksViewChanges is set to YES by default if iconView is not nil). | ||
| */ |
There was a problem hiding this comment.
@PhamBaTho Can you give this a more specific prop type?
|
At what stage this PR? I use a fork with |
|
@satori-ytolstoguzov if you could address the comments (if @PhamBaTho won't) I can have a look |
|
@rborn @satori-ytolstoguzov @PhamBaTho - we've merged this back in November: #1705 and it exposes |
|
@compojoom It seems merged PR forgot to add that to the docs. Other than that I don't see any differences |
|
@satori-ytolstoguzov could you test if it's working and make a PR for documentation? I'll be here to merge it ❤️ |
|
@rborn It's a busy day, will look into that on Monday. Also would you consider useful if I add one more bridged property: |
|
i'm testing on maps provider google and default. |
|
trackViewChange prop has been added here: 78a36ac |
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
…erformance (#2650) * Added icon property - react-native-maps/react-native-maps#1491 * fixed MapMarker.js indentation * Added support for Marker icon property on android * Added support for Marker icon property on android
Expose tracksViewChanges property of GMSMarker. By default, this property is YES.
Setting
tracksViewChangeto NO appropriately can solve some performance issues causing high CPU load on iOS (e.g. #1031 , #1176).The followings are some guidelines relating to
tracksViewChangeI extracted from Google Maps SDK documentation:Please note that this property has no effect if iconView of marker is nil. In other words, I don't think we have any issue with performance if we use default marker.
I have tested on iOS simulator with many use cases like adding many markers on maps, drawing polyline between markers, animating custom markers... and the CPU remains in good health when the map is idle.
Sample usage: