rnmapbox / rnmapbox/maps

[Bug]: PointAnnotation renders underneath other layers

Open
#3,732 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug 🪲
Dominant language
Kotlin
Stars
2.9k
Forks
947
Avg merge
6d 37m
Merged PRs (30d)
1

Description

Mapbox Implementation

Mapbox GL

Mapbox Version

10.1.32

React Native Version

0.74.5

Platform

iOS, Android

@rnmapbox/maps version

10.1.32-beta.11

Standalone component to reproduce
import React, { useState } from 'react';
import { LineLayer, ShapeSource, PointAnnotation } from '@rnmapbox/maps';
import { View } from 'react-native';
import { Button } from 'react-native-paper';

const EditFieldBoundary = () => {
 const featureCollection = () => {
   return {
     type: 'FeatureCollection',
     features: [
       {
         type: 'Feature',
         id: 'a-feature',
         properties: {},
geometry: {
           type: 'LineString',
           coordinates: [74,7354736583765,36.84765843584],
         },
       }
     ]
   };
 };

 const [selectedCoordinates, setSelectedCoordinates] = useState();
 const [draggedPoint, setDraggedPoint] = useState({ index: -1, point: null });

 const draggingEditablePoint = (feature) => {
  console.log(feature)
 };

 const changeCoordinate = (feature) => {
  console.log(feature)
 }

 return (
   <>
     <ShapeSource id="dottedLineSource" shape={featureCollection()}>
       <LineLayer
         id="dottedLineLayer"
         sourceID="dottedLineSource"
         style={{
           lineWidth: 2,
           lineColor: 'white',
           lineDasharray: ['literal', [1, 1]]
         }}
       />
     </ShapeSource>
     {selectedCoordinates?.length > 0 &&
       selectedCoordinates?.map((coord, index) => {
         return (
           <PointAnnotation
             key={`vertex-${index}`}
             id={`vertex-${index}`}
             coordinate={coord}
             style={{ zIndex: 1000 }}
             draggable
             onSelected={(feature) => {}}
             onDragStart={(feature) => {
               setDraggedPoint({
                 index,
                 point: [feature.geometry.coordinates[0], feature.geometry.coordinates[1]]
               });
             }}
             onDrag={(feature) => draggingEditablePoint(feature)}
             onDragEnd={(feature) => changeCoordinate(feature)}>
             <View
               style={{
                 zIndex: 100000,
                 width: 20,
                 height: 20,
                 borderRadius: 50,
                 backgroundColor: 'black',
                 justifyContent: 'center',
                 borderColor: 'white',
                 borderWidth: 2
               }}
             />
           </PointAnnotation>
         );
       })}
   </>
 );
};

export default EditFieldBoundary;
Observed behavior and steps to reproduce

I have a use case where I need to show a circle shape for all the vertices for the polygon and should able to drag the vertices circle to adjust the polygon shape (Attached Image). I am using Pint Annotation along with the LineLayer for this use case but point annotation always comes underneath the line layer. I have tried solutions like setting the higher zIndex for the point annotation or rendering point annotation after line layer rendering is done but nothing seems to be working. Could someone please help here since this is a blocker for the whole feature?
Screenshot 2025-01-02 at 11 24 06 AM

Expected behavior

There should be a way where i should able move the point annotation above any other layer.

Notes / preliminary analysis

No response

Additional links and references

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. Start by running the provided PointAnnotation and LineLayer reproduction on iOS and Android, then trace how their rendering order is determined; done means the point annotations render above the line layer while remaining draggable.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.