nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 697 forks source link

BackgroundLayer ignore alpha opacity on Android #1510

Open StefanoCremona opened 5 years ago

StefanoCremona commented 5 years ago

No way to have a transparent background with the BackgroundLayer component on Android. On iOS it works well on the other hand. :-(

const layerStyles = MapboxGL.StyleSheet.create({
  overlay: {
    backgroundColor: 'rgba(0, 0, 0, 0.4)'
  }
})

export const overlay = layerStyles.overlay

export default class Map extends React.Component {

  render() {

    return (
      <MapboxGL.MapView
        styleURL={'mapbox://styles/mapbox/streets-v10'}
        style={{
          flex: 1
        }}
        centerCoordinate={[ 11.9788354, 57.6962992 ]}
      >
        <MapboxGL.VectorSource>
          <MapboxGL.BackgroundLayer id='backgroundOpacity' style={overlay}/>
        </MapboxGL.VectorSource>
      </MapboxGL.MapView>
    );
  }
}

screenshot 2019-02-18 at 12 49 19 screenshot 2019-02-18 at 12 49 12

kristfal commented 5 years ago

This issue extends to all alpha colors, eg: rgba and hsla for Android. This is likely the root cause.

ghost commented 5 years ago

Hi, i was running on the same issue but i found that the lib provides the backgroundOpacity style prop and it handles opacity on both plaforms. I think this issue should be closed. @nitaliano