Ol-Cesium@2.10.0 + OpenLayers@6.1.1 + Angular@8.2.0 (Problem)
See original GitHub issueI’m trying to integrate olcesium with my application, and I can’t figure it out, how to do it. I’m relative new with angular and I dont know how to use that UMD file mentioned at intall tutorial.
Can someone help me configure my app to run a simple 3d Map with openlayer OSM at Angular 8?
My steps were:
Install the package:
npm i --save ol-cesium
adding OLCesium.js to scripts Path at “Angular.json”:
...
],
"scripts": [
"node_modules/bootstrap/js/src/util.js",
"node_modules/ol-cesium/src/olcs/OLCesium.js"
]
},
...
imported the package as the tutorial said with some changes:
...
import OLCesium from 'ol-cesium/src/olcs/OLCesium.js'; << using this way
import OLCesium from 'olcs/OLCesium.js'; <<< this way was giving error olcs not found
...
build a map with OpenLayers, then input that map inside the cesium object:
startMap(){
this.view = new View({
center: this.brasil,
zoom: 8
});
this.map = new Map({
target: 'map',
layers: [this.OSMLayer],
loadTilesWhileAnimating: true,
loadTilesWhileInteracting: false,
view: this.view
});
var ol3d = new OLCesium({map: this.map}); // ol2dMap is the ol.Map instance
ol3d.setEnabled(true);
}
And when I run the code, I get this error.
ERROR ReferenceError: Cesium is not defined
at new OLCesium (OLCesium.js:173)
at MapaComponent.setMap (mapa.component.ts:86)
at MapaComponent.ngOnInit (mapa.component.ts:48)
at checkAndUpdateDirectiveInline (core.js:31910)
at checkAndUpdateNodeInline (core.js:44367)
at checkAndUpdateNode (core.js:44306)
at debugCheckAndUpdateNode (core.js:45328)
at debugCheckDirectivesFn (core.js:45271)
at Object.eval [as updateDirectives] (HomeComponent.html:9)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:45259)
Can some one help me do it, at least, show the map?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Downloads for the v7.2.2 release - OpenLayers
The recommended way to use OpenLayers is to work with the ol package. To add OpenLayers to an existing project, install the latest...
Read more >OpenLayers 6.1.1 Vector Layer Memory Leak - Stack Overflow
This is my code for destroying the layers. Has anyone encountered this issue in version 6 of OpenLayers post beta? const layers =...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
These were the steps that I took to make it work using Ol-Cesium@2.10.0 + OpenLayers@6.1.1 + Angular@8.2.0:
Install cesium, openlayer and ol-cesium(for angular)
npm i cesium ol ol-cesium
Edited my angular.json for Cesium and OL
**If you need to use Ion Features, you will need to add your personal token, add it at environment and import it at your main.ts for usage.
<div style="width:100vw; height:100vh" id="map"></div>
And that was all! hope it help someone out there! 🤣 If you do these steps I think you’ll get your 3d map aswell, good luck and have fun.
Happy you found out a solution @Jarn40. Thanks for sharing your experience.