This example shows how to use Cesium and Leaflet, and how to swich between the map views in React.
This example uses the following of Norkart's services:
- Norkart Maptiles
- Norkart 3D tiles
- Norkart WMS-Høyde(terrain provider for cesium)
- Norkart WMS-Orto(imagery provider for cesium)
- Request API access here.
- Typescript - Language.
- React - Front end library.
- Leaflet - For rendering the interactive map.
- React Leaflet - For integrating leaflet with react.
- Material-UI - For design system and components.
- Cesium - For rendering the interactive map
- Resium - For integrating cesium with react.
- Webpack - Javascript Bundler.
- This is a React App. To run it locally you will need to use npm to install packages and run the app.
- Add
.env
to the root folder, and provide the follwing values:
REACT_APP_TILE_MAP_SERVICE_IMAGERY_PROVIDER_URL=
REACT_APP_TERRAIN_PROVIDER_URL=
REACT_APP_3D_TILES_PROVIDER_URL=
REACT_APP_MAPTILES_PROVIDER_URL=
- In
Map.tsx
, components which will rendered in both the Leaflet and Cesium view are specified. - In this example we add the
SwitchMode.tsx
component, so we can toggle between the map views. - Components are rendered, using
MapControls.tsx
.
- Map bounds are used to determine where to render the map in case of a map swich.
MapOrchestrator.tsx
holds the bounds state, so it can be updated fromm either the Leaflet or Cesium component.- For Leaflet, bounds are updated in
EventHandler.tsx
- For Cesium, bounds are updated in
CameraPosition.tsx
The following guides have been used to build the webpack.config file: