Does anybody integrate the last OpenLayers with Vaadin flow using npm and webpack?
I tried the following steps (based on paper-slider example in the documentation):
npm install ol in the project directory
create component class with annotations:
@Tag("ol")
@NpmPackage(value = "ol", version = "6.1.1")
@JavaScript("ol/main.js")
public class Ol extends Component {
...
}
and javascript main.js containing code for create the simple map:
var map = new Map({
target: 'map',
layers: [
new TileLayer({
source: new XYZ({
url: 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'
})
})
],
view: new View({
center: [0, 0]
,
zoom: 2
})
});
Insert the component to the layout:
...
Ol ol = new Ol();
ol.setId("map");
add(ol);
...
There is no effect on the page, only empty tag
During the deployment I see webpack log messages noted that all javascripts including OpenLayers and mine was accepted and build.
I would be appreciated for any advice.
Dear Jean!
Yes, this works fine, thanks.
There were no javascript errors because we have run “npm install” manually (without annotation as in your example)