MonkeyBonkey
MonkeyBonkey

Reputation: 47881

Can you customize the current location marker in react native maps?

I'd like to use a custom marker image instead of the pulsing blue dot - is there a way to customize this in react native maps using apple maps for ios and google maps for Android?

Upvotes: 7

Views: 12321

Answers (3)

veelon
veelon

Reputation: 66

Adding to what the others have said, you can use the MapView's onUserLocationChange event directly without installing a dependency like @react-native-community/geolocation. This only works if showsUserLocation is set to true.

If you are using Expo, you can use expo-location's API to get the last user location.

Upvotes: 0

Phil Mok
Phil Mok

Reputation: 4050

As far as I know, you cannot change the default current location dot. A work around is to pass the user's location into a <Marker /> with your custom image and turn off showsUserLocation to hide the default blue dot. Here are the Marker docs.

Then you can track the user's location using Geolocation.watchPosition. If you set the user's location to state it will trigger a rerender when the user moves.

Upvotes: 5

Carlos Guillen
Carlos Guillen

Reputation: 26

You can create a custom marker and hook up an event listener to track the user and update the location of the marker as your user moves.

This event listener is available within the framework. https://facebook.github.io/react-native/docs/geolocation.html#watchposition

Upvotes: 0

Related Questions