in modules/react-map-gl-draw/src/edit-modes/editing-mode.ts [254:298]
_getCursorEditHandle(event: PointerMoveEvent, feature: Feature) {
// event can be null when the user has not interacted with the map whatsoever
// and therefore props.lastPointerMoveEvent is still null
// returning null here means we can e.g. set a featureIndex without requiring an event
if (!event) {
return null;
}
// @ts-expect-error check event type
const { isDragging, picks } = event;
// if not pick segment
const picked = picks && picks[0];
if (!picked || !isNumeric(picked.featureIndex) || picked.type !== ELEMENT_TYPE.SEGMENT) {
return null;
}
// if dragging or feature is neither polygon nor line string
if (
isDragging ||
(feature.geometry.type !== GEOJSON_TYPE.POLYGON &&
feature.geometry.type !== GEOJSON_TYPE.LINE_STRING)
) {
return null;
}
const insertMapCoords = this._getPointOnSegment(feature, picked, event.mapCoords);
if (!insertMapCoords) {
return null;
}
return {
type: 'Feature',
properties: {
guideType: GUIDE_TYPE.CURSOR_EDIT_HANDLE,
shape: feature.properties.shape,
positionIndexes: [-1],
editHandleType: 'intermediate',
},
geometry: {
type: GEOJSON_TYPE.POINT,
coordinates: insertMapCoords,
},
};
}