MyGit

openlayers/ol-cesium

Fork: 328 Star: 1005 (更新于 2024-10-25 13:54:50)

license: BSD-2-Clause

Language: TypeScript .

OpenLayers - Cesium integration

最后发布版本: v2.20 ( 2024-04-24 17:28:06)

官方网址 GitHub网址

OpenLayers - Cesium library

OLCS is an opensource JS library for making OpenLayers and CesiumJS works together, in the same application. It addresses several use-cases:

  • [Adding 3D to an existing OpenLayers map](#Adding 3D to an existing OpenLayers map)
  • [Extending CesiumJS with new capabilities](#Extending CesiumJS with new capabilities)
  • [Cherry-picking the pieces you need](#Cherry-picking the pieces you need)

See live examples.

The npm package is called olcs. Note that CesiumJS is accessed through the global window.Cesium object.

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.

Adding 3D to an existing OpenLayers map

// Create an OpenLayers map or start from an existing one.
import Map from 'ol/Map.js';
const ol2dMap = new Map({
    ...
});
ol2dMap.addLayer(....)
// Pass the map to the OL-Cesium constructor
// OL-Cesium will create and synchronize a 3D CesiumJs globe from your layers and data.
import OLCesium from 'olcs';
const ol3d = new OLCesium({map: ol2dMap});
ol3d.setEnabled(true); // switch to 3D - show the globe
ol3d.setEnabled(false); // switch to 2D - show the map

Build with your prefered bundler.

You can use any version of CesiumJS: latest upstream, a fork... Simply provide it as window.Cesium global:

<script src="https://cesium.com/downloads/cesiumjs/releases/1.113/Build/Cesium/Cesium.js"></script>

Extending CesiumJS with new capabilities

// Start from a CesiumJS globe
const viewer = getYourCesiumJSViewer();

// Add OpenLayers imagery provider
import {OLImageryProvider} from 'olcs';
viewer.scene.imageryLayers.addImageryProvider(new OLImageryProvider(...));

// Add Mapbox MVT imagery provider (client side rendering)
import {MVTImageryProvider} from 'olcs';
viewer.scene.imageryLayers.addImageryProvider(new MVTImageryProvider(...));

This is a bit limited at the moment but idea would be to implement:

  • client side reprojection;
  • full client side MVT rendering;
  • GeoTIFF rendering;
  • ... any feature available in OpenLayers.

Cherry-picking the pieces you need

Specific low level functionnalities can be cherry-picked from the library. For example:

// GoogleMap rotating effect
import {rotateAroundBottomCenter} from 'olcs';
rotateAroundBottomCenter(viewer.scene, someAngle);
// convert OpenLayers Vector Layer to CesiumJS primitives
import {FeatureConverter} from 'olcs';
const converter = new FeatureConverter(viewer.scene);
const featurePrimitiveMap: Record<number, PrimitiveCollection> = {};
const counterpart: VectorLayerCounterpart = this.converter.olVectorLayerToCesium(olLayer, view, featurePrimitiveMap);
const csPrimitives = counterpart.getRootPrimitive();
viewer.scene.primitives.add(csPrimitives);
// Even more powerful, use a synchronizer
import {VectorSynchronizer} from 'olcs';
const synchronizer = new VectorSynchronizer(ol2dMtheap, viewer.scene);

If you think some low level features should be spotlited here, open an issue and let's discuss it.

Configuration

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

Also, check the api doc.

Limitations due to OpenLayers

There are a few limitations due to decisions on

Contributing

See CONTRIBUTING.md.

最近版本更新:(数据更新于 2024-10-20 06:59:32)

2024-04-24 17:28:06 v2.20

2024-01-17 00:56:03 v2.17

2023-08-28 17:33:55 v2.15.2

2023-08-24 19:28:05 v2.15.1

2023-07-27 20:07:12 v2.15

2023-07-14 15:22:32 v2.14

2022-09-09 16:19:40 v2.13.1

2021-05-21 19:52:06 v2.13

2019-04-15 19:27:40 v2.9.0

2018-11-09 18:33:18 v2.5

主题(topics):

3d, cesium, openlayers

openlayers/ol-cesium同语言 TypeScript最近更新仓库

2024-11-05 17:55:23 langgenius/dify

2024-11-05 17:35:52 siyuan-note/siyuan

2024-11-05 16:59:32 laurent22/joplin

2024-11-05 12:39:27 lobehub/lobe-chat

2024-11-05 11:52:31 RSSNext/Follow

2024-11-05 07:18:03 microsoft/genaiscript