Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions demo/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ var interactPlugin = createInteractPlugin({
},{
layerId: 'linked-parcels',
// idProperty: 'id'
},{
layerId: 'OS/TopographicArea_1/Agricultural Land'
}],
interactionMode: 'auto', // 'auto', 'select', 'marker' // defaults to 'marker'
interactionMode: 'select', // 'auto', 'select', 'marker' // defaults to 'marker'
multiSelect: true,
contiguous: true,
// excludeModes: ['draw']
Expand Down Expand Up @@ -106,6 +108,7 @@ var interactiveMap = new InteractiveMap('map', {
containerHeight: '650px',
transformRequest: transformTileRequest,
enableZoomControls: true,
readMapText: true,
// enableFullscreen: true,
// hasExitButton: true,
// markers: [{
Expand Down Expand Up @@ -149,7 +152,6 @@ interactiveMap.on('app:ready', function (e) {
})

interactiveMap.on('map:ready', function (e) {
// console.log('map:ready')
// framePlugin.addFrame('test', {
// aspectRatio: 1
// })
Expand Down Expand Up @@ -178,7 +180,7 @@ interactiveMap.on('draw:ready', function () {
// drawPlugin.split('test1234', {
// snapLayers: ['OS/TopographicArea_1/Agricultural Land']
// })
// drawPlugin.newLine('test', {
// drawPlugin.newPolygon('test', {
// snapLayers: ['OS/TopographicArea_1/Agricultural Land']
// })
// drawPlugin.editFeature('test1234')
Expand Down
2 changes: 1 addition & 1 deletion demo/js/planning.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const interactiveMap = new InteractiveMap('map', {
// search
})

interactiveMap.on('map:ready', function (e) {
interactiveMap.on('app:ready', function (e) {
interactiveMap.addButton('menu', {
label: 'Menu',
panelId: 'menu',
Expand Down
8 changes: 8 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,14 @@ See [PluginDescriptor](./plugins/plugin-descriptor.md) for full details.

---

### `preserveStateOnClose`
**Type:** `boolean`
**Default:** `false`

Controls whether closing the map (via the browser back button or the exit map button when `hasExitButton` is `true` and the map is fullscreen) destroys the map instance or hides it while preserving its current state. Set to `true` to keep the map state intact, which is useful for implementations like a toggle map view list view pattern.

---

### `readMapText`
**Type:** `boolean`
**Default:** `false`
Expand Down
6 changes: 4 additions & 2 deletions plugins/beta/draw-ml/src/mapboxSnap.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ function applyMapboxSnapPatches(colors) {
function pollUntil(checkFn, onSuccess) {
(function poll() {
const result = checkFn()
// null signals to stop polling, falsy continues polling
if (result === null) return
result ? onSuccess(result) : requestAnimationFrame(poll)
})()
}
Expand Down Expand Up @@ -267,7 +269,7 @@ export function initMapLibreSnap(map, draw, snapOptions = {}) {
// Handle style changes - re-patch source and ensure snap layer exists
map.on('style.load', () => {
pollUntil(
() => map.getSource('mapbox-gl-draw-hot'),
() => map._removed ? null : map.getSource('mapbox-gl-draw-hot'),
(source) => {
patchSourceData(source)

Expand Down Expand Up @@ -312,7 +314,7 @@ export function initMapLibreSnap(map, draw, snapOptions = {}) {

// Initial setup - poll until draw source exists
pollUntil(
() => map.getSource('mapbox-gl-draw-hot'),
() => map._removed ? null : map.getSource('mapbox-gl-draw-hot'),
createSnap
)
}
9 changes: 8 additions & 1 deletion plugins/interact/src/hooks/useInteractionHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ export const useInteractionHandlers = ({
useEffect(() => {
// Skip if features exist but bounds not yet calculated
const awaitingBounds = selectedFeatures.length > 0 && !selectionBounds
if (awaitingBounds || selectedFeatures === lastEmittedSelectionChange.current) {
if (awaitingBounds) {
return
}

// Skip if selection was already empty and remains empty
const prev = lastEmittedSelectionChange.current
const wasEmpty = prev === null || prev.length === 0
if (wasEmpty && selectedFeatures.length === 0) {
return
}

Expand Down
Loading