Locking the extent that a user can pan and zoom out #7199
-
Hi all, sorry for this newbie question. I've trawled around and around on this and have received a very authoritative answer from ChatGPT (pasted below) - can someone please guide on this ... Need is - to lock the terriamap service to within a set North, South, East, West box so that - 1. the user focuses on the local story being told and 2. the service is not being used and charged for delivering global data. Yes, I've created initialview - the need is to set overall map extent. I ask how to do this in the way that TerriaMap is set up . Ideally so that I can edit one or some json config files and not have to try stumbling into coding within terria.js. Can someone please guide on this? CHATGPT Text follows - You are an expert in terria.js - please guide on how to set the extent box in latitude and longitude within which a user can view the map ChatGPT Configuring via Initialization File json Programmatically Setting the Extent javascript const terria = new Terria({ terria.initSources.push({ terria.start().then(() => { // Define the extent // Apply the extent We initialize Terria with the base URL. please continue with this answer - I am asking how to limit a user to only view within a box defined by North south east west or lat and lon coordinates ChatGPT How to Limit a User to View Only Within a Defined Box in TerriaJS🗒️ Answer Configuration in Initialization File json javascript // Initialize Terria terria.initSources.push({ terria.start().then(() => { // Define the extent // Apply the extent // Limit panning to within the extent Notes: 🌐 Sources |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi Matt thanks for reaching out. Currently there is no configuration to lock the view to a certain extent. |
Beta Was this translation helpful? Give feedback.
Hi Matt thanks for reaching out. Currently there is no configuration to lock the view to a certain extent.
It would be possible to implement this by listening to camera events and restricting camera movements manually. See the Cesium documentation: https://cesium.com/learn/cesiumjs/ref-doc/Camera.html