question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android: PointAnnotation renders underneath other layers

See original GitHub issue

When PointAnnotation is rendered in the same space as another layer (such as LineLayer, or RasterLayer) it shows underneath the other layer. This is almost never what you would want.

It would be ideal if we could select where the PointAnnotation renders using something similar to aboveLayerID and belowLayerID, but as a default case I think it should render on top of all the other layers (I can’t think of many cases where you wouldn’t want this anyway).

Repro

image

<MapboxGL.MapView style={{ flex: 1 }}>
  <MapboxGL.Camera
    bounds={{
      ne: [2, 2],
      sw: [-2, -2],
    }}
  />
  <MapboxGL.ShapeSource
    id="line-source"
    shape={
      {
        type: 'Feature',
        geometry: {
          type: 'LineString',
          coordinates: [[1, 1], [-1, -0.7]],
        },
      }
    }
  />

  <MapboxGL.LineLayer
    id="line-layer"
    sourceID="line-source"
  />
  <MapboxGL.PointAnnotation
    id="point"
    coordinate={[0, 0]}
  />
</MapboxGL.MapView>

Changing the order of the elements in code appears to have no effect.

Interestingly if you put content in the PointAnnotation it renders on top with iOS and under in android.

image

        <MapboxGL.PointAnnotation
          id="point"
          coordinate={[-0.1, 0]}
        >
          <Text>test</Text>
        </MapboxGL.PointAnnotation>

By pushing it under one of the builtin layers on android this behaviour can be changed eg:

image

        <MapboxGL.LineLayer
          id="line-layer"
          sourceID="line-source"
          style={{ lineWidth: 8, lineColor: 'white' }}
          belowLayerID={Platform.OS === 'android' ? 'mapbox-android-symbol-layer-1' : undefined}
        />

Versions:

  • Platform: Both
  • Device: iPhone 11 13.4, Pixel 2 8.1
  • Emulator/ Simulator: have tried on both emulator and physical
  • react-native-mapbox-gl Version 8.0.0-rc1
  • React Native Version 0.62

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
ydhnwbcommented, Apr 12, 2022

any update of this?

3reactions
roncodescommented, May 5, 2021

+1 will try and use SymbolLayer for now, but would be nice if PointAnnotation could be rendered above LineLayer on android

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android: PointAnnotation renders underneath other layers #806
When PointAnnotation is rendered in the same space as another layer (such as LineLayer, or RasterLayer) it shows underneath the other layer.
Read more >
pointannotation is not working in android - Stack Overflow
I don't have issue real device and emulator. It is behave same in both. In Android it is going under other layers, that...
Read more >
rnmapbox/Lobby - Gitter
next question, it looks like PointAnnotation renders under other layers (this ... On android the layer id might-be: mapbox-android-symbol-layer-0 or ...
Read more >
PointAnnotationManager - Mapbox docs
PointAnnotation Manager. The pointAnnotation manager allows to add pointAnnotations to a map. class PointAnnotationManager(mapView: View, delegateProvider: ...
Read more >
Style Layers | Maplibre gl native ios | MapTiler
Use a background style layer to configure a color or pattern to show below all other map content. If the style's other layers...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found