mapbox / mapbox/mapbox-gl-draw
Argument of type 'MapboxDraw' is not assignable to parameter of type 'IControl'
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 612
- Avg merge
- 8d 9h
- Merged PRs (30d)
- 5
Description
**@mapbox/mapbox-gl-draw:** ^1.4.3,
**@mapbox/mapbox-gl-draw-static-mode:** ^1.0.1,
**mapbox-gl:** ^3.2.0,
### Steps to Trigger Behavior
#### Code
```tsx
modes.static = StaticMode
const draw = new MapboxDraw({
displayControlsDefault: false,
touchEnabled: true,
modes,
styles: [
// ACTIVE (being drawn)
// line stroke
{
id: "gl-draw-line",
type: "line",
filter: ["all", ["==", "$type", "LineString"], ["!=", "mode", "static"]],
layout: {
"line-cap": "round",
"line-join": "round",
},
paint: {
"line-color": "#84cc16",
"line-width": 2, // Line width
"line-opacity": 1, // Fully opaque lines
},
},
// polygon fill
{
id: "gl-draw-polygon-fill",
type: "fill",
filter: ["all", ["==", "$type", "Polygon"], ["!=", "mode", "static"]],
paint: {
"fill-color": "#84cc16",
"fill-outline-color": "#84cc16",
"fill-opacity": 0.1, // Semi-opaque fill
},
},
// polygon outline stroke
// This doesn't style the first edge of the polygon, which uses the line stroke styling instead
{
id: "gl-draw-polygon-stroke-active",
type: "line",
filter: ["all", ["==", "$type", "Polygon"], ["!=", "mode", "static"]],
layout: {
"line-cap": "round",
"line-join": "round",
},
paint: {
"line-color": "#84cc16", // Red color for polygon outline
"line-width": 2, // Line width
"line-opacity": 1, // Fully opaque outline
},
},
// vertex point halos
{
id: "gl-draw-polygon-and-line-vertex-halo-active",
type: "circle",
filter: ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"], ["!=", "mode", "static"]],
paint: {
"circle-radius": 10,
"circle-color": "#FFF", // White color for vertex halo
},
},
// vertex points
{
id: "gl-draw-polygon-and-line-vertex-active",
type: "circle",
filter: ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"], ["!=", "mode", "static"]],
paint: {
"circle-radius": 8,
"circle-color": "#84cc16", // Red color for vertex points
},
},
// Inactive polygon fill
{
id: "gl-draw-polygon-fill-static",
type: "fill",
filter: ["all", ["==", "$type", "Polygon"], ["==", "mode", "static"]],
paint: {
"fill-color": "#3b82f6", // Blue color for inactive polygon fill
"fill-outline-color": "#3b82f6", // Blue outline
"fill-opacity": 0.1, // Semi-opaque fill
},
},
// Inactive polygon outline stroke
{
id: "gl-draw-polygon-stroke-static",
type: "line",
filter: ["all", ["==", "$type", "Polygon"], ["==", "mode", "static"]],
layout: {
"line-cap": "round",
"line-join": "round",
},
paint: {
"line-color": "#3b82f6", // Blue color for inactive polygon outline
"line-width": 2, // Line width
"line-opacity": 1, // Fully opaque outline
},
},
// Inactive vertex points
{
id: "gl-draw-polygon-and-line-vertex-static",
type: "circle",
filter: ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"], ["==", "mode", "static"]],
paint: {
"circle-radius": 3,
"circle-color": "#3BB2D0", // Blue color for inactive vertex points
},
},
],
// Set mapbox-gl-draw to draw by default.
// The user does not have to click the polygon control button first.
// defaultMode: drawMode,
})
mapRef.current.addControl(draw, "top-right")
```
### Expected Behavior
Types compatible
### Actual Behavior

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 at the TypeScript error on mapRef.current.addControl(draw, "top-right") and compare MapboxDraw's control declaration with mapbox-gl's IControl definition. Reproduce it with the listed package versions; done means the draw instance is accepted by addControl without a type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100