mapbox-gl-draw icon indicating copy to clipboard operation
mapbox-gl-draw copied to clipboard

Unable to generate midpoints when creating a polygon (just looking for potential suggestions)

Open Vladis466 opened this issue 4 years ago • 1 comments

Hello, just looking to gain a little more insight into a particular issue. I seem to be unable to generate a line or polygon with mid points.

I've gone so far as to try to force the issue by calling the underlying function that handles midpoint creation manually but still no midpoints. This is a preliminary post as I really don't have enough information to say if i've found a bug. I was hoping to get some insight into what could potentially be causing this to do a bit more research.

This code snippet below shows how I am attempting to insert the drawable on the map.

`

let featureId = draw.add(polygon);

let temp = draw.get(featureId);  //sanity checking the polygon is added

draw.changeMode(draw.modes.DIRECT_SELECT, {
  featureId,
});

createSupplementaryPoints(temp, {midpoints: true});

`

mapbox-gl-js version: "mapbox-gl": "^2.6.1", mapbox-gl-draw version: "@mapbox/mapbox-gl-draw": "^1.3.0",

Expected Behavior

Midpoints are created on feature added /w direct select

Actual Behavior

Midpoints not created.

###Additional Info Map.Draw geometries are overlaid on top of generated colored geometries. You can see that in the image below. There can be any number of points, lines, and polygons on a map simultaneously. I don't use the native provided buttons to draw but have created my own which call the same underlying events. (no custom handlers are used).

image

Vladis466 avatar Dec 03 '21 11:12 Vladis466

While editing, have you tried a style like:

                {
                    id: "gl-draw-polygon-midpoint",
                    type: "circle",
                    filter: ["all", ["==", "$type", "Point"], ["==", "meta", "midpoint"]],
                    paint: {
                        "circle-radius": 4,
                        "circle-color": "#FFc000",
                    },
                },

jaybo avatar Jan 08 '22 03:01 jaybo