maps: [Bug]: inconsistent iconSize between iOS and Android
Mapbox Implementation
Mapbox
Mapbox Version
default
Platform
iOS, Android
@rnmapbox/maps version
10.0.11
Standalone component to reproduce
import React from 'react';
import {
Images,
MapView,
ShapeSource,
SymbolLayer,
Camera,
} from '@rnmapbox/maps';
const styles = {
mapView: { flex: 1 },
iconLayer: {
iconSize: 3.0,
iconImage: 'example'
},
};
const features = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
id: 'a-feature',
geometry: {
type: 'Point',
coordinates: [-74.00597, 40.71427],
},
},
],
};
class BugReportExample extends React.Component {
render() {
return (
<MapView style={styles.mapView}>
<Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
<Images images={{ example: require('../assets/example.png') }} />
<ShapeSource id={'shape-source-id-0'} shape={features}>
<SymbolLayer
id="symbol-id"
style={styles.iconLayer}
/>
</ShapeSource>
</MapView>
);
}
}
export default BugReportExample;
Observed behavior and steps to reproduce
Images on iOS are are ≈2.5x larger than on Android:
Expected behavior
Same size on both device types.
Notes / preliminary analysis
React 18.2.0 React Native 0.72.4 @rnmapbox/maps 10.0.11
Additional links and references
Previous related bug: https://github.com/rnmapbox/maps/issues/68
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 20 (13 by maintainers)
The issues should have been fixed
10.1.0-beta.10, can you pls confirm?note from paul’s teammate: we haven’t been able to determine yet whether this is a bug in our code which generates the icon image per platform, or a bug in rnmapbox’s icon scaling, so if this can’t be reproduced it should be safe to close out
I’m seeing something similar, but with the built-in user heading icon. On iOS in the dev client the image is the proper size, but when built for production the image looks about 3x too big.
Dev Client
Production Build
update: current best guess is that it is due to
rnmapboxignoring thescaleattribute ofImageURISources passed intoMapbox.Images’simagesargument on Android only. in our case we couldn’t avoid using thescaleattribute due to the way our vector icon library generates images, so we are trying to work around by multiplying the size of the icon on Android only byPixelRatio.get(). will update again if this resolves on all platforms once it gets pushed to more users’ devices.