mapbox / mapbox/mapbox-maps-android
New Feature: Add API to draw a “direction cone” (sector shape) easily
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 578
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Description
### Description
Currently, the Mapbox Maps SDK for Android does not provide a built-in way to render a *direction cone* (also known as a sector, view cone, or field-of-view arc).
Developers must manually compute latitude/longitude points along an arc and create a polygon to visualize a directional area — for example, a **Qibla direction cone** or **camera field of view**.
This requires repetitive math and custom logic:
* Computing arc coordinates using spherical trigonometry
* Handling wrap-around at 0°/360° and anti-meridian crossings
* Creating polygons manually with `PolygonAnnotation` or `FillLayer`
#### Example use case
Visualizing directional areas such as:
* Camera or compass “view cones”
* Radar or sensor field of view
* Qibla direction cone from a user’s location
#### Suggested solution
Add a lightweight helper API to easily draw a directional cone centered on a `Point`, given:
* `center`: geographic point (latitude, longitude)
* `bearing`: direction in degrees
* `halfAngle`: cone spread in degrees
* `radius`: distance in meters or kilometers
* `fillColor` / `fillOpacity`: optional styling
##### Example usage
```kotlin
mapView.annotations.createDirectionCone(
center = Point.fromLngLat(lon, lat),
bearing = heading,
halfAngle = 25.0,
radius = 300000.0, // meters
fillColor = Color.parseColor("#6600EEFF"),
fillOpacity = 0.35
)
```
Expected behavior:
* SDK internally computes and renders the cone polygon
* Automatically handles projection and anti-meridian issues
* Provides consistent results across zoom levels and map projections
---
## Why
Drawing a simple fan-shaped area currently requires non-trivial math and boilerplate, which developers have to reimplement in every project.
A built-in API would:
* Simplify rendering of directional indicators
* Reduce code duplication across apps
* Improve maintainability and readability
* Enable new UX patterns (e.g., navigation view cones, AR guidance, Qibla direction indicators)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the mapView.annotations entry point and review the existing PolygonAnnotation and FillLayer approaches mentioned in the issue. Clarify the API design and verify that the resulting cone supports the listed center, bearing, halfAngle, radius, styling, projection, and anti-meridian requirements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100