react-native-maps custom marker image (Android)


#1

Has anyone been able to get a custom image marker working with react-native-maps on Android. Right now I have it working by using the image prop but I need to be able to use a custom component for the marker. Any help would be appreciated. Thanks!


#2

Sorry if I’m missing something, but would this work for you?

class Marker extends React.Component {
  render() {
    const { image, imageStyle, children, ...props } = this.props;
    const { OS } = Platform;
    return (
      <MapView.Marker image={OS === 'android' ? image : undefined}>
        {OS === 'ios' && <Image source={image} style={imageStyle} />}
        {children}
      </MapView.Marker>
    );
  }
}

Related: https://github.com/expo/expo/issues/1182#issuecomment-397695647


#3

That is what I’m doing now, I have a custom image component for the Marker on iOS and using the the image prop for Android. But I want to be able to use a custom image component for Android as well. I would like to use a text view or maybe a video as the marker but with Android you can’t use any custom component for the marker, only the image prop works.


#4

Expo.MapView is using the AirBnB maps module. Here is an issue related to your issue: https://github.com/react-community/react-native-maps/issues/1870 lol it’s pretty popular


#5

Yeah I see your reply now, you will probably have better luck there. Possibly open a PR. I feel like someone may have already opened a PR to try and fix this.
Also, when it get’s updated be sure to let us know - I don’t think we keep up-to-date with each release, but I could be wrong…


#6

Yeah I have been following that issue for awhile (years) but nothing has been fixed or changed on their end. Was just wondering if anyone here has figured out a way to do it.


#7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.