Skip to content

OfflineGuide

Corey Koval edited this page Jul 31, 2022 · 7 revisions

Using DF Aggregator Offline

A typical installation of DFA requires a connection to the internet in order to access the CesiumJS library and access map data. This guide will show you how to load the CesiusJS library offline and display a very simple map. For more complicated tile server connections, please see the documentation for CesiumJS and your tile server.

Download CesiumJS

There are two methods available for downloading the CesiumJS library. Please select the method best suited to your situation.

Method 1: Using npm

  1. Check that npm is installed on your system. If it is not, refer to your OS's instructions for installing npm.

    • npm --version
  2. Navigate to the df-aggregator/static/ directory.

    • cd static
  3. Install the CesiumJS library.

    • npm install cesium

Method 2: Direct Download

  1. Download the latest version of CesiumJS from here: https://cesium.com/downloads/cesiumjs/

  2. Create a folder named cesium under df-aggregator/static/

  3. Extract the contents of the CesiumJS library to the cesium/ folder you just created.

Link to the local version of CesiumJS

  1. Open views/cesium.tpl in a text editor.

  2. Look for the following lines:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/cesium/1.95.0/Cesium.js"
    integrity="sha512-Y95sidA9cDT2a8MMmD47EyCVxQRJYNhXEnvBgbsp+q0gK2k3VSMpMvs9DTct0dEjm+6Dru+d2wYllhgceEiFgw=="
    crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/cesium/1.95.0/Widgets/widgets.min.css"
    integrity="sha512-dWztHlhNizO37Lu3hJ+wCd8/T/VTqD8PHp4ZHRpHuGvEJJ59vTD0LPXekgZiaghVYDyZvXAqTAVhuctgyyukgw=="
    crossorigin="anonymous" referrerpolicy="no-referrer" />
    
  3. Update the URLs to reflect the local library.

    • If you used npm, update the lines to show:
    <script src="/static/node_modules/cesium/Build/Cesium/Cesium.js"></script>
    <link href="/static/node_modules/cesium/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
    
    • If you did the direct download, update them to show:
    <script src="/static/cesium/Build/Cesium/Cesium.js"></script>
    <link href="/static/cesium/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
    
  4. Set the map to default to offline data:

    1. Look for the following lines in cesium.tpl:
    var viewer = new Cesium.Viewer('cesiumContainer', {
      imageryProvider: esri,
      // imageryProvider : new Cesium.TileMapServiceImageryProvider({
      //   url : Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII')
      // }),
      sceneModePicker: true,
      homeButton: false,
      timeline: false,
      mapProjection : new Cesium.WebMercatorProjection(),
    });
    
    1. Comment out the esri imagery provider, then remove the comments from the imageryProvider section:
    var viewer = new Cesium.Viewer('cesiumContainer', {
      // imageryProvider: esri,
      imageryProvider : new Cesium.TileMapServiceImageryProvider({
        url : Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII')
      }),
      sceneModePicker: false,
      homeButton: false,
      timeline: false,
      mapProjection : new Cesium.WebMercatorProjection(),
    });
    
Clone this wiki locally