Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 853
MonkeyBonkey Avatar asked May 07 '18 15:05

MonkeyBonkey


People also ask

How do I change the marker in react-native maps?

Adding a marker in React Native Mapsimport { Marker } from "react-native-maps"; Next, render the <Marker /> component as a child of <MapView /> . Pass the coordinate for the marker in the coordinate prop.

How do I get my current location in react-native?

Geolocation is enabled by default when you create a project with react-native init . In order to enable geolocation in the background, you need to include the 'NSLocationAlwaysUsageDescription' key in Info. plist and add location as a background mode in the 'Capabilities' tab in Xcode.


1 Answers

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.

like image 96
Phil Mok Avatar answered Oct 11 '22 07:10

Phil Mok