initMap() {
map = new Map({
layers: [
new TileLayer({
source: new OSM(),
}),
],
target: 'map',
view: new View({
center: [116.403218, 39.92372],
zoom: 12,
maxZoom: 18,
projection: 'EPSG:4326',
constrainResolution: true,
smoothResolutionConstraint: false,
}),
});
this.addPoint()
},
addPoint() {
let feature = new Feature({
title: 'beijing',
geometry: new Point([116.403218, 39.92372]),
})
feature.setStyle(
new Style({
image: new CircleStyle({
fill: new Fill({
color: 'blue',
}),
radius: 4,
}),
})
);
let source = new VectorSource()
source.addFeature(feature)
let layer = new VectorLayer()
layer.setSource(source)
map.addLayer(layer)
},