• Stars
    star
    982
  • Rank 46,621 (Top 1.0 %)
  • Language
    TypeScript
  • License
    BSD 2-Clause "Sim...
  • Created over 10 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

OpenLayers - Cesium integration

OpenLayers - Cesium integration library. Create your map using OpenLayers, and visualize it on a globe with Cesium. See live examples.

ES6 modules

Since version 2.0, the code is entirely based on ES6 modules and syntax. It requires OpenLayers 6.x. A convenient ES6 package olcs is available on npm.

Features

Switch smoothly between 2D and 3D and synchronize:

  • Map context (bounding box and zoom level);
  • Raster data sources;
  • Vector data sources in 2D and 3D;
  • Map selection (selected items);
  • Animated transitions between map and globe view.

The library is configurable and extensible and allows:

  • Lazy or eager loading of Cesium
  • Limiting Cesium resource consumption (idle detection)

For synchronization of maps in projections other than EPSG:4326 and EPSG:3857 you need 2 datasets, see the customProj example.

Integration in your application

There are several ways to integrate OL-Cesium in your application. In all cases OpenLayers and Cesium are peer-dependencies of OL-Cesium, your application need to depend on a compatible version of OpenLayers and of Cesium. Note that Cesium is accessed through the global window.Cesium object. OpenLayers is accessed through ES6 imports.

As an ES6 library (recommended method)

npm i --save olcs

Then import the parts you need. Example:

import OLCesium from 'olcs/OLCesium.js';
const ol3d = new OLCesium({map: ol2dMap}); // ol2dMap is the ol.Map instance
ol3d.setEnabled(true);

In addition, you need to expose the Cesium library as window.Cesium. For this, simply add the Cesium script to your html:

<script type="text/javascript" src="..your_path../Cesium.js"></script>

For Cesium integration with Webpack, see ol-cesium-webpack-example.

As an old-fashioned independent library (need update)

  • build the library in dist/olcs.js:
npm i --save olcs
npm run build-library
const ol3d = new olcs.OLCesium({map: ol2dMap}); // ol2dMap is the ol.Map instance
ol3d.setEnabled(true);

For the remaining steps, see the old fashioned example. Notably, you need the Cesium library.

As an UMD library (Angular, ...)

npm i --save ol-cesium

The UMD-specific build is located here: node_modules/ol-cesium/dist/olcesium.umd.js

Then import the parts you need. Example:

import OLCesium from 'ol-cesium';
const ol3d = new OLCesium({map: ol2dMap}); // ol2dMap is the ol.Map instance
ol3d.setEnabled(true);

In addition, you need to expose the Cesium library as window.Cesium. For this, simply add the Cesium script to your html:

<script type="text/javascript" src="..your_path../Cesium.js"></script>

Going further

See the examples.

Use properties to control specific aspects of OL-Cesium integration, see the PROPERTIES.MD.

If you are new to Cesium, you should also check the Cesium tutorials.

Running the examples in debug mode

This is useful for contributing to Ol-Cesium, because it loads the source files instead of a minified build:

$ make serve

will make the distribution examples available at http://localhost:3000/examples

Running the unminified version of Cesium

Passing the parameter ?mode=dev to an example will load the debug version of Cesium instead of the minified one. This is helpful when something breaks inside Cesium. In distribution mode, an unminified version of OpenLayers and Ol-Cesium is also loaded.

Limitations

  • OpenLayers unmanaged layers are not discoverable and as a consequence not supported. Plain layers should be used instead of the synchronization managed manually. See #350.

  • OpenLayers interactions are not supported in 3d. See #655.

Release process

See RELEASE.md.

More Repositories

1

openlayers

OpenLayers
JavaScript
11,232
star
2

ol2

OpenLayers v2 - deprecated!
JavaScript
1,477
star
3

ol-mapbox-style

Use Mapbox Style objects with OpenLayers
JavaScript
335
star
4

workshop

JavaScript
72
star
5

ol-webpack

OpenLayers + webpack
JavaScript
52
star
6

ol-vite

Using OpenLayers with Vite
HTML
31
star
7

create-ol-app

Set up a new OpenLayers based application
JavaScript
23
star
8

jsdoc-plugin-typescript

Plugin to make TypeScript's JSDoc type annotations work with JSDoc
JavaScript
22
star
9

ol-parcel

OpenLayers + Parcel
HTML
21
star
10

openlayers.github.io

OpenLayers website source
18
star
11

closure-util

Utilities for Closure Library based projects
JavaScript
18
star
12

ol-skypack

Using OpenLayers with Skypack
HTML
11
star
13

ol-browserify

Using browserify and the ol package
JavaScript
10
star
14

ol3-unleashed

Slideshow
JavaScript
10
star
15

ol-rollup

OpenLayers + Rollup
JavaScript
9
star
16

builder

OpenLayers 3 builder
JavaScript
6
star
17

ol-esbuild

OpenLayers + esbuild
JavaScript
6
star
18

docs

OpenLayers 2 documentation
HTML
5
star
19

grunt-openlayers

Common Grunt tasks for OpenLayers development, website building, etc.
JavaScript
5
star
20

babel-plugin-jsdoc-closure

Transpiles JSDoc types from namepaths to types for Closure Compiler
JavaScript
5
star
21

mapbox-to-css-font

Utility to convert Mapbox GL Style font names to CSS font definitions
JavaScript
4
star
22

feature-frenzy

OpenLayers Feature Frenzy
JavaScript
4
star
23

openlayers-closure-application

Sample application describing how to compile the application and OpenLayers code together
HTML
4
star
24

website

OpenLayers 2 website source
CSS
4
star
25

builder-client

Client for the OpenLayers build service
JavaScript
3
star
26

eslint-config-openlayers

ESLint config for OpenLayers
JavaScript
3
star
27

closure-es-modules

Using the Closure Compiler with ES modules
JavaScript
2
star
28

webpack-jsdoc-closure-loader

A webpack loader that converts JSDoc types from namepaths to types for Closure Compiler
JavaScript
2
star
29

art

Logos, themes, and things like that for the website
HTML
2
star
30

bench

A place for examples that can be used to test performance
JavaScript
2
star
31

cla

Contributor License Agreements
2
star
32

libtess

A slightly modified copy of https://github.com/brendankenny/libtess.js
JavaScript
2
star
33

f4gna18-frenzy

FOSS4G-NA '18 Talk
JavaScript
2
star
34

webpack-closure-suppress-loader

Loader that suppresses all warnings Closure Compiler would issue when compiling the source
1
star
35

archive

Archive for older https://openlayers.org content
HTML
1
star
36

builder-util

Code shared by the OpenLayers build server and client
JavaScript
1
star
37

data

JavaScript
1
star
38

eslint-plugin

Custom ESLint rules for OpenLayers
JavaScript
1
star