Skip to content

Files

Latest commit

b6a5b2a · Feb 26, 2025

History

History

hslayers-cesium-app

Installation

npm install hslayers-cesium-app

Create empty html page and include <hslayers-cesium-app></hslayers-cesium-app> Where you want the map to appear (See example).

Include HSLayers-NG styles in page <head>:

<link rel="stylesheet" href="node_modules/hslayers-cesium-app/styles.css">

Include hslayers-cesium-app bundle scripts after <hslayers-cesium-app>:

<script src="node_modules/hslayers-cesium-app/runtime.js"></script>
<script src="node_modules/hslayers-cesium-app/polyfills-es5.js"></script>
<script src="node_modules/hslayers-cesium-app/polyfills.js"></script>
<script src="node_modules/hslayers-cesium-app/vendor.js"></script><!-- Must be included since 4.x -->
<script src="node_modules/hslayers-cesium-app/main.js"></script>

Configuration

A global hslayersNgConfig function and cesium specific hslayersCesiumConfig, which return a configuration objects, NEED TO BE CREATED BEFORE loading the main.js script. Functions return a JSON objects that describes the application's look, behavior and data to display. See Hslayers configuration options and Cesium configuration options for the list of available config options. HSLayers-ng exposes OpenLayers as global 'ol' variable, which is used in defining layers and configuration. Example

<script>
    function hslayersNgConfig(ol) {
      return {
        assetsPath: 'node_modules/hslayers-cesium-app/assets/',
        default_layers: [],

        default_view: new ol.View({
          center: ol.proj.fromLonLat([17.474129, 52.574000]),
          zoom: 4,
        })
      }
    } 

    function hslayersCesiumConfig() {
        return {
          cesiumBase: 'node_modules/hslayers-cesium-app/assets/cesium/',
        };
      }
  </script>