-
-
Notifications
You must be signed in to change notification settings - Fork 816
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
Android - make it possible to change image for existing image ID, improve performance of DownloadMapImageTask #3431
Android - make it possible to change image for existing image ID, improve performance of DownloadMapImageTask #3431
Conversation
- improve performance of DownloadMapImageTask - download images in parallel using Kotlin coroutines
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.
@Buthrakaur thanks much for the PR, looks nice!
Pls add a simple component to the PR description to reproduce the issue this solves.
Hi @mfazekas , sorry for the late response - I just updated the PR description. The update of image in |
I have tested the new feature on /example
|
@Buthrakaur I wasn't able to use your component as it uses lot of thing not included. I could reproduce the issue and confirm the fix using this component: import React from 'react';
import {
MapView,
Images,
Camera,
SymbolLayer,
ShapeSource,
} from '@rnmapbox/maps';
import { Button } from 'react-native';
import exampleIcon from '../assets/compass1.png';
import exampleIcon2 from '../assets/compass2.png';
const styles = {
icon: {
iconImage: ['get', 'icon'],
iconSize: [
'match',
['get', 'icon'],
'example',
1.2,
'airport-15',
1.2,
/* default */ 1,
],
iconAllowOverlap: true,
},
matchParent: { flex: 1 },
};
const featureCollection = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
id: '9d10456e-bdda-4aa9-9269-04c1667d4552',
properties: {
icon: 'example',
},
geometry: {
type: 'Point',
coordinates: [-117.20611157485, 52.180961084261],
},
},
{
type: 'Feature',
id: '9d10456e-bdda-4aa9-9269-04c1667d4552',
properties: {
icon: 'example2',
},
geometry: {
type: 'Point',
coordinates: [-117.205908, 52.180843],
},
},
],
};
class Example extends React.Component {
state = {
images: {
example: exampleIcon2,
example2: exampleIcon,
},
i: 0,
};
render() {
const { images, i } = this.state;
return (
<>
<MapView style={styles.matchParent}>
<Camera
defaultSettings={{
zoomLevel: 16,
centerCoordinate: [-117.20611157485, 52.180961084261],
}}
/>
<Images images={images} />
<ShapeSource id="exampleShapeSource" shape={featureCollection}>
<SymbolLayer id="exampleIconName" style={styles.icon} />
</ShapeSource>
</MapView>
<Button
title="Change"
onPress={() =>
this.setState({
images: {
...this.state.images,
example: i === 0 ? exampleIcon : exampleIcon2,
example2: i === 0 ? exampleIcon2 : exampleIcon,
},
i: i === 0 ? 1 : 0,
})
}
/>
</>
);
}
}
export default Example; |
@@ -142,6 +142,10 @@ dependencies { | |||
// React Native | |||
implementation "com.facebook.react:react-native:+" | |||
|
|||
// kotlin coroutines | |||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : '1.6.21'}" |
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.
Unfortunately kotlinx-coroutines-core doesn't correlates to the Kotlin version 1 to 1, this break RN 0.74 code which sets kotlinVersion = '1.9.22'
https://react-native-community.github.io/upgrade-helper/?from=0.73.7&to=0.74.0
Description
Fixes #3331
Checklist
CONTRIBUTING.md
yarn generate
in the root folder/example
app./example
)Screenshot OR Video
Component to reprocuce the issue you're fixing