版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/funkstill/article/details/86575505
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://openlayers.org/en/v5.3.0/css/ol.css" type="text/css">
<style>
.map{
height: 400px;
width:100%;
}
</style>
<script src="https://openlayers.org/en/v5.3.0/build/ol.js"></script>
<title>Hello OpenLayers</title>
</head>
<body>
<h2>My Map</h2>
<div id = "map" class="map"></div>
<script type="text/javascript">
var map = new ol.Map({
target:'map',
layers:[
new ol.layer.Tile({
source:new ol.source.OSM()
})
],
view:new ol.View({
center:ol.proj.fromLonLat([121.654959,42.046233]),
zoom:13
})
});
</script>
</body>
</html>