A few additional notes of caution when using queryRenderedFeatures().
Here's the object returned, which contains a bunch of non-standard "GeoJSON Feature Object" properties:
{
_geometry:{type: 'Point', coordinates: Array(2)}
_vectorTileFeature:Au {properties: {…}, extent: 8192, type: 1, _pbf: xc,
_geometry: 164, …}
id:undefined
layer:{id: 'markers-layer-public',
type: 'symbol', source: 'markers-
source-public', layout: {…}, paint: {…}}
properties:{isMarker: true, name: 'Point Wilson', icon: 'coastpilot',
access: 'public', id: 'GNIS1507543'}
source:'markers-source-public'
state:{}
type:'Feature'
geometry (get):ƒ geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}
geometry (set):ƒ geometry(t){this._geometry=t;}
}
Note the get/set methods for .geometry. This means a simple copy will fail, ie. you can't use:
const featureCopy = {...feature} // this won't copy the geometry!
Instead use:
const featureCopy = {
type: feature.type,
layer: {...feature.layer}, // if you need this
properties: {...feature.properties},
geometry: {...feature.geometry}
};
Also, note that the .id property is undefined. I'm not sure if this is related to using mapboxgl Draw, but the .id property isn't correctly returned even if it was set when the feature was added to the map.