When upgrading my Angular Cli application to OpenLayers 6.2.1 from 5.3.3, zooming en panning using the mouse and mousewheel stopped working.
To Reproduce
Steps to reproduce the behavior:
Zooming and panning both work
to:
"@types/ol": "^6.1.0",
"ol": "^6.2.1",
Zooming and panning do not work
Expected behavior
Zooming and panning using the mouse should work in a minimal Angular Cli application.
You need to make sure that ol/ol.css is properly loaded. The import 'ol/ol.css'; line you have in your map component does not do what you expect it to do in a standard angular-cli config. See https://stackoverflow.com/questions/40071845/how-to-import-css-from-node-modules-in-webpack-angular2-app for more details.
Thanks! You nailed the problem. After I added "node_modules/ol/ol.css" to the styles section of angular.json, the Zoom In and Zoom Out buttons rendered correctly and the Zoom and Pan using the mouse did work. You need to give the map the focus first though...
@ligtendag Your solution works, thanks !
Most helpful comment
Thanks! You nailed the problem. After I added "node_modules/ol/ol.css" to the styles section of angular.json, the Zoom In and Zoom Out buttons rendered correctly and the Zoom and Pan using the mouse did work. You need to give the map the focus first though...