react-native-maps: Unable to Increase Marker Size Beyond 38 Units in react-native-maps
Summary
I’m experiencing an issue where I cannot increase the size of a custom marker beyond approximately 38 units in react-native-maps. Regardless of the dimensions I set, the marker seems to have a maximum size limit and won’t scale up as expected.
Reproducible sample code
import React from "react";
import { View, StyleSheet, Image } from "react-native";
import MapView, { Marker } from "react-native-maps";
const CustomMarkerExample = () => {
const myLocation = {
latitude: 37.78825,
longitude: -122.4324,
heading: 0,
};
return (
<View style={styles.container}>
<MapView
style={styles.map}
initialRegion={{
latitude: myLocation.latitude,
longitude: myLocation.longitude,
latitudeDelta: 0.005,
longitudeDelta: 0.005,
}}
>
<Marker
coordinate={{
latitude: myLocation.latitude,
longitude: myLocation.longitude,
}}
anchor={{ x: 0.5, y: 0.5 }}
flat={true}
>
<View style={styles.markerContainer}>
<Image
source={require("./path-to-your-image.png")}
style={styles.markerImage}
resizeMode="contain"
/>
</View>
</Marker>
</MapView>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
map: {
...StyleSheet.absoluteFillObject,
},
markerContainer: {
width: 75, // Attempting to set width larger than 38
height: 75, // Attempting to set height larger than 38
alignItems: "center",
justifyContent: "center",
},
markerImage: {
width: "100%",
height: "100%",
},
});
export default CustomMarkerExample;
Steps to reproduce
Create a MapView component from react-native-maps. Add a Marker component with a custom image inside an Animated.View or View. Set the width and height of the image or container to values larger than 38. Run the app and observe the marker size on the map.
Expected result
The marker should display at the dimensions specified (e.g., 75x75 units), scaling the image accordingly.
Actual result
The marker does not increase in size beyond approximately 38 units, regardless of the dimensions set in styles.
React Native Maps Version
1.20.1
What platforms are you seeing the problem on?
Android
React Native Version
0.76.3
What version of Expo are you using?
SDK 52
Device(s)
Pixel 7A
Additional information
The issue persists regardless of the image or component used within the Marker. It appears there might be a limitation on marker size imposed by the underlying native map SDKs or the react-native-maps library itself.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 9
- Comments: 18
Still relevant
I was in headache because of this…
still relavant
Still relevant
still relavant
Still relevant
Same for me, it’s been months
still relevant
still relevant