Skip to content

Instantly share code, notes, and snippets.

@staffordsmith83
Last active October 12, 2022 06:33
Show Gist options
  • Save staffordsmith83/e701ea3ee7604c310e91e79098e6899f to your computer and use it in GitHub Desktop.
Save staffordsmith83/e701ea3ee7604c310e91e79098e6899f to your computer and use it in GitHub Desktop.
Instructions how to get the camera position from TerriaMap

How to get the camera position from TerriaMap

Say you want to set the homeCamera for your TerriaMap, in simple.json.

{
  "homeCamera": {
    "north": -8,
    "east": 158,
    "south": -45,
    "west": 109
  },

A great way is to load up a terriamap application, zoom it to the initial view that you want, and then export the homeCamera using this hack:

  1. Load up http://ci.terria.io/main/ or your own TerriaMap.
  2. Zoom and pan the map the the initial view that you want
  3. Click "Share/Print" in the top right corner, and copy the sharelink that is generated: Pasted image 20221012141057
  4. Edit the sharelink, remove the # character and replace = with / . So http://ci.terria.io/main/#share=s-jfDtTYNWzrirJAqJ8i0Os0vLgNg becomes http://ci.terria.io/main/share/s-jfDtTYNWzrirJAqJ8i0Os0vLgNg
  5. Paste the sharelink back in a browser (E.g. Google Chrome)
  6. A json file will download. This has a property called initialCamera, e.g.
"initialCamera": {
    "west": 111.10075541006248,
    "south": -28.743217852536166,
    "east": 117.02473704913916,
    "north": -22.885793583925707,
    "position": {
      "x": -2297942.36437604,
      "y": 5309829.666896026,
      "z": -3321174.578815482
    },
    "direction": {
      "x": -0.07821051151218932,
      "y": -0.1155917786552186,
      "z": 0.9902129349772829
    },
    "up": {
      "x": -0.4680551830939547,
      "y": 0.8812384818747622,
      "z": 0.06590207615810807
    }
  },
  1. Replace the homeCamera value in your simple.json file with the initialCamera value. It should look something like this:
{
  "homeCamera": {
    "west": 111.10075541006248,
    "south": -28.743217852536166,
    "east": 117.02473704913916,
    "north": -22.885793583925707,
    "position": {
      "x": -2297942.36437604,
      "y": 5309829.666896026,
      "z": -3321174.578815482
    },
    "direction": {
      "x": -0.07821051151218932,
      "y": -0.1155917786552186,
      "z": 0.9902129349772829
    },
    "up": {
      "x": -0.4680551830939547,
      "y": 0.8812384818747622,
      "z": 0.06590207615810807
    }
  },
  "catalog": [
    {
      "id": "ZIdekvc10z",
      "type": "wms-group",
      "name": "Test",
      "url": "https://programs.communications.gov.au/geoserver/ows",
      "members": [
      // ETC...

Save simple.json and refresh your TerriaMap page. Should update the initial view! Pasted image 20221012142401

NB: The properties position, direction, and up are optional. You could just use this for a more simple "top down" initial view:

{
  "homeCamera": {
    "west": 111.10075541006248,
    "south": -28.743217852536166,
    "east": 117.02473704913916,
    "north": -22.885793583925707
  },
  "catalog": [
    {
      "id": "ZIdekvc10z",
      "type": "wms-group",
      "name": "Test",
      "url": "https://programs.communications.gov.au/geoserver/ows",
      "members": [
      // ETC...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment