Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom map styles, custom markers and marker pin color not working on Android #2105

Closed
prathammehta opened this issue Mar 17, 2018 · 17 comments

Comments

@prathammehta
Copy link

Is this a bug report?

Yes

Have you read the Installation Instructions?

Yes

Environment

react-native: 0.51.0
react: 16.0.0

Steps to Reproduce

  1. Create a react native app using react-native init.
  2. Follow installation instructions to the dot.
  3. Use Google custom style generator to generate a custom style.
  4. Add custom style prop to Map component

Expected Behavior

  1. Custom map style would show up on Android and iOS

Actual Behavior

  • Custom style works on iOS
  • Custom style does not work on Android.

img_4365
screenshot_1521311365

@willbattel
Copy link
Contributor

Can you please share what react-native-maps version and play-services-maps version you're using? The latest versions are 0.20.1 and 11.8.0 respectively.

@prathammehta
Copy link
Author

Hey,
Sorry for the delayed response.

react-native-maps version is 0.20.1
Google play services are set to 11.8.0

Still doesn't work.

@willbattel
Copy link
Contributor

Okay. Can you share the code for you MapView component?

Also, a new version of react-native-maps was just recently published. Try updating to v0.21.0. (Note that this will require Gradle version 3.0.0 or greater. See here.)

@prathammehta
Copy link
Author

This is the code for the MapView component:

<MapView style={{position:'absolute', height:'100%', width:'100%'}} initialRegion={{ latitude: currentLocation.coords.latitude, longitude: currentLocation.coords.longitude, latitudeDelta: intitialMapDelta, longitudeDelta: intitialMapDelta, }} showsUserLocation={true} mapPadding={mapPadding} ref={c => this.mapView = c} customMapStyle={Static.MapStyle} provider={Platform.OS == 'ios'?PROVIDER_GOOGLE:null} >

Also just realised the following aren't working on Android either:

  • Custom marker images
  • Marker pin color

@prathammehta prathammehta changed the title Custom map styles not working on Android Custom map styles, custom markers and marker pin color not working on Android Apr 6, 2018
@prathammehta
Copy link
Author

I've also updated to v0.21.0 and Gradle 3.0.1
Experiencing the same problems.

@willbattel
Copy link
Contributor

willbattel commented Apr 6, 2018

How come your provider prop has that ternary? You're setting the provider to null on Android, which may or may not be causing the problem.

Replace provider={Platform.OS == 'ios'?PROVIDER_GOOGLE:null} with provider={"google"} and see if it helps.

@prathammehta
Copy link
Author

Hey,

Sorry for the delayed response. Been trying to fix this issue for over a month now. Still nothing. @wbattel4607 I tried what you've suggested. Not working. :/

@willbattel
Copy link
Contributor

Can you share your MapView component code again, this time with my suggested code included?

@prathammehta
Copy link
Author

Yup. Here it is:

<MapView style={{ position: 'absolute', height: '100%', width: '100%' }} initialRegion={{ latitude: currentLocation.coords.latitude, longitude: currentLocation.coords.longitude, latitudeDelta: intitialMapDelta, longitudeDelta: intitialMapDelta, }} maxZoomLevel={14.5} showsUserLocation={true} mapPadding={mapPadding} ref={c => this.mapView = c} customMapStyle={constants.MapStyle} provider={PROVIDER_GOOGLE} > { //Polyline to destination (this.state.polylinePlotted && this.state.destination) && <MapViewDirections origin={currentLocation.coords} destination={this.state.destination.coords} apikey={constants.googleAPIKey} strokeWidth={3} strokeColor="black" onReady={this.fitMapToCoordsAndFetchPickupoints} /> } { // Markers for pickup points // NEEDS TO BE ENABLED PROPERLY FOR PRODUCTION. this.state.pickupPoints && this.state.pickupPoints.map((pickupPoint) => { // if (pickupPoint.id != this.state.focusedPickupPoint.id) { return ( <Marker coordinate={{latitude: pickupPoint.latitude, longitude: pickupPoint.longitude}} image={pickupPoint.id === this.state.focusedPickupPoint.id?redCircle:greyCircle} tracksViewChanges={false} /> ) }) } </MapView>

@willbattel
Copy link
Contributor

Hmm. Nothing obvious is wrong. Are there any warnings in the debug log?

What version(s) of Android have you tried? Try different API levels on the emulator and see if there is any change in behavior.

@gkemp94
Copy link

gkemp94 commented Jun 5, 2018

Also having this issue, will post my code later this week.

@prathammehta
Copy link
Author

@gkemp94 could you post your code please.

@prathammehta
Copy link
Author

@wbattel4607 Have tried many different versions of android and different API levels. Same issue everywhere. It's really hard to figure this out as somethings work on the map and others do not.

@willbattel
Copy link
Contributor

@prathammehta try changing your provider from PROVIDER_GOOGLE to "google"

@rborn
Copy link
Collaborator

rborn commented Oct 12, 2018

Closing, old issue

@rborn rborn closed this as completed Oct 12, 2018
@patrickmuhi
Copy link

Thanks guys

@GabrielScalici
Copy link

GabrielScalici commented Aug 14, 2019

Allowed colors for Marker are : red, tomato, orange, yellow, green, gold, wheat, linen, tan, blue, aqua, teal, violet, purple, indigo, turquoise, navy and plum.
Like:
<MapView.Marker
pinColor={'green'}
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants