Skip to content

Commit 768a673

Browse files
committed
Allow a way to use default icon prop
1 parent acedce8 commit 768a673

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/maps/src/components/MapMarker.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
View,
66
StyleSheet,
77
Text,
8+
Platform,
89
} from "react-native";
910
import { Marker as MapMarkerComponent } from "./react-native-maps";
1011
import type {
@@ -20,6 +21,7 @@ export interface MapMarkerProps
2021
longitude: number;
2122
pinImage?: string | ImageSourcePropType;
2223
pinImageSize?: number;
24+
androidUseDefaultIconImplementation?: boolean;
2325
onPress?: (latitude: number, longitude: number) => void;
2426
}
2527

@@ -40,6 +42,7 @@ export function renderMarker(
4042
longitude,
4143
pinImage,
4244
pinImageSize = 50,
45+
androidUseDefaultIconImplementation = false,
4346
onPress,
4447
children,
4548
title,
@@ -76,6 +79,9 @@ export function renderMarker(
7679
);
7780
}
7881

82+
const shouldUseDefaultIconImplemnation =
83+
Platform.OS !== "android" || !androidUseDefaultIconImplementation;
84+
7985
return (
8086
<MapMarkerComponent
8187
ref={ref}
@@ -89,11 +95,18 @@ export function renderMarker(
8995
const coordinate = event.nativeEvent.coordinate;
9096
onPress?.(coordinate.latitude, coordinate.longitude);
9197
}}
98+
icon={
99+
shouldUseDefaultIconImplemnation
100+
? typeof pinImage === "string"
101+
? { uri: pinImage }
102+
: (pinImage as any)
103+
: undefined
104+
}
92105
{...rest}
93106
>
94107
{nonCalloutChildren}
95108

96-
{pinImage && (
109+
{pinImage && !shouldUseDefaultIconImplemnation && (
97110
<Image
98111
testID="map-marker-pin-image"
99112
source={typeof pinImage === "string" ? { uri: pinImage } : pinImage}

0 commit comments

Comments
 (0)