Skip to content
Merged
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
9 changes: 8 additions & 1 deletion plugins/draw/src/adapters/openlayers/snap/snapEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ const buildTileBoundaryState = (layer, map) => {
const getClipContext = (state, coord) => {
if (!state) { return null }
const { tileGrid, viewProj, sourceProj, zoom } = state
const toSource = (c) => c ? projTransform(c, viewProj, sourceProj) : null
// Same-code projections need no reprojection — skipping the call also avoids depending
// on ol/proj's registry having a transform for the pair, which can be missing when the
// draw plugin and the map provider ship as separate bundles each with their own ol/proj4.
const codeOf = (projection) => (typeof projection === 'string' ? projection : projection.getCode())
const toSource = (coordinate) => {
if (!coordinate) { return null }
return codeOf(sourceProj) === codeOf(viewProj) ? coordinate : projTransform(coordinate, viewProj, sourceProj)
}
const anchor = toSource(coord)
const tileCoord = tileGrid.getTileCoordForCoordAndZ(anchor, zoom)
const extent = tileGrid.getTileCoordExtent(tileCoord)
Expand Down
Loading