-
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
Expose tracksViewChange and icon property to improve some performance issues #1491
Conversation
UPDATE: The We still need to have a better naming between |
@@ -260,13 +273,20 @@ class MapMarker extends React.Component { | |||
image = image.uri; | |||
} | |||
|
|||
let icon; | |||
if (this.props.icon) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would refactor this to ternary if statement :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
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: |
@@ -17,6 +18,7 @@ | |||
| `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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PhamBaTho Is this prop iOS only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only applicable for iOS. Android don't have issues with that.
* because it doesn't trigger tracksViewChanges. | ||
* (tracksViewChanges is set to YES by default if iconView is not nil). | ||
*/ | ||
icon: PropTypes.any, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
Expose tracksViewChanges property of GMSMarker. By default, this property is YES.
Setting
tracksViewChange
to NO appropriately can solve some performance issues causing high CPU load on iOS (e.g. #1031 , #1176).The followings are some guidelines relating to
tracksViewChange
I 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: