Skip to content

Commit

Permalink
Merge pull request #1076 from dbauszus-glx/mapview-extent
Browse files Browse the repository at this point in the history
mapview.extent
  • Loading branch information
RobAndrewHurst authored Jan 24, 2024
2 parents 62d4532 + ecc025f commit f1b9f8f
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions lib/mapview/_mapview.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,18 @@ export default (mapview) => {
])

// WARN!
mapview.locale.bounds && console
.warn('locale.bounds have been renamed to locale.extent')

if (mapview.locale.extent) {
const north = parseFloat(mapview.locale.extent.north || 90);
const south = parseFloat(mapview.locale.extent.south || -90);
const east = parseFloat(mapview.locale.extent.east || 180);
const west = parseFloat(mapview.locale.extent.west || -180);

if ((north - south) >= 0 && (east - west) >= 0) {
mapview.extent = ol.proj.transformExtent([west, south, east, north], 'EPSG:4326', `EPSG:${mapview.srid}`);
} else {
console.warn('Invalid extent. Ensure north >= south and east >= west. Global extent is assumed.');
}
mapview.locale.bounds && console.warn('locale.bounds have been renamed to locale.extent')

const north = parseFloat(mapview.locale.extent?.north || 90);
const south = parseFloat(mapview.locale.extent?.south || -90);
const east = parseFloat(mapview.locale.extent?.east || 180);
const west = parseFloat(mapview.locale.extent?.west || -180);

if ((north - south) >= 0 && (east - west) >= 0) {
mapview.extent = ol.proj.transformExtent([west, south, east, north], 'EPSG:4326', `EPSG:${mapview.srid}`);
} else {
console.warn('Invalid extent. Ensure north >= south and east >= west. Global extent is assumed.');
mapview.extent = ol.proj.transformExtent([-180, -90, 180, 90], 'EPSG:4326', `EPSG:${mapview.srid}`);
}

// Map
Expand Down

0 comments on commit f1b9f8f

Please sign in to comment.