React-native-mapbox-gl: Android annotationImage doesn't work

Created on 26 Jul 2016  路  8Comments  路  Source: nitaliano/react-native-mapbox-gl

It seem that annotationImage doesn't work on Android.
By changing the image uri, it still display the same default red marker.

Android bug

Most helpful comment

@dapetcu21
Thanks for the guide.
It's working now.
By the way , thanks for you contribution on react-native-mapbox-gl.
It really helps a lot.

All 8 comments

annotationImage does indeed not work yet on Android if you use remote images. Have you tried with local images?

@dapetcu21
Thanks for the fast reply.
I'm not sure what's the correct format ?
annotationImage: { source: { require('./Img/item.png') }, height: 25, width: 25 },

After taking a brief look at RNMGLAnnotationOptionsFactory.java .
I'm still confuse with the format of using local images

It's

annotationImage: {
  source: { uri: 'item' }
  height: 25,
  width: 25
}

Then, as the docs state, you put your image in android/app/src/main/res/drawable/item.png

I have confirmed annotationImage to be working on both Android and iOS with local images. I'm actually using it in a production app. You must be doing something wrong. Check that you're using source: { uri: 'item' }, check that the image is in drawable at that exact location, check that the uri does not contain the .png extension.

@dapetcu21
Thanks for the guide.
It's working now.
By the way , thanks for you contribution on react-native-mapbox-gl.
It really helps a lot.

I'll close this and open a new issue about remote images on android

If the marker is in the drawable location, will it also work for iOS? I have it now working for Android with a local image - but now the iOS marker isn't showing up. I am assuming because the file is in an android folder.

Where should the local image be placed for iOS, so that I can use the syntax, and have it work for both devices?

annotationImage: {
  source: { uri: 'marker' },
  height: 25,
  width: 25
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

lernerbot picture lernerbot  路  3Comments

Gp2mv3 picture Gp2mv3  路  3Comments

yaduc picture yaduc  路  3Comments

smoll picture smoll  路  4Comments

Maxence-Machu picture Maxence-Machu  路  3Comments