const map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
],
view: new ol.View({
center: ol.proj.fromLonLat([116.39123296750768, 39.907180309385694]),
zoom: 8
})
});
<div id="map"></div>
html,body {
margin: 0;
padding: 0;
height: 100%;
}
#map {
height: 100%;
width: 100%;
}