-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Expose tracksViewChange and icon property to improve some performance issues #1491
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,14 @@ const propTypes = { | |
| */ | ||
| image: PropTypes.any, | ||
|
|
||
| /** | ||
| * Marker icon to render (equivalent to `icon` property of GMSMarker Class). | ||
| * 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). | ||
| */ | ||
| icon: PropTypes.any, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @PhamBaTho Can you give this a more specific prop type? |
||
|
|
||
| /** | ||
| * Opacity level of view/image based markers | ||
| */ | ||
|
|
@@ -60,6 +68,11 @@ const propTypes = { | |
| */ | ||
| pinColor: PropTypes.string, | ||
|
|
||
| /** | ||
| * Controls whether the icon for the marker should be redrawn every frame. | ||
| */ | ||
| tracksViewChanges: PropTypes.bool, | ||
|
|
||
| /** | ||
| * The coordinate for the marker. | ||
| */ | ||
|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. I would refactor this to ternary if statement :)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
| icon = resolveAssetSource(this.props.icon) || {}; | ||
| icon = icon.uri; | ||
| } | ||
|
|
||
| const AIRMapMarker = this.getAirComponent(); | ||
|
|
||
| return ( | ||
| <AIRMapMarker | ||
| ref={ref => { this.marker = ref; }} | ||
| {...this.props} | ||
| image={image} | ||
| icon={icon} | ||
| style={[styles.marker, this.props.style]} | ||
| /> | ||
| ); | ||
|
|
||
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.