Quickstart Guide to OpenLayers

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>Quickstart Guide to OpenLayers</title>
    <style>
      html, body, #map-view-div {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    </style>
    <link rel="stylesheet" href="/my-content/libs/ol/ol.css" />
    <!-- https://cdn.jsdelivr.net/npm/ol@v8.2.0/ol.css -->
    <script src="/my-content/libs/ol/dist/ol.js"></script>
    <!-- https://cdn.jsdelivr.net/npm/ol@v8.2.0/dist/ol.js -->
  </head>
  <body>
    <div id="map-view-div"></div>
    <script>
      const map = new ol.Map({
        target: "map-view-div",
        layers: [
          new ol.layer.Tile({
            source: new ol.source.OSM(),
          })
        ],
        view: new ol.View({
          center: ol.proj.fromLonLat([25.2797, 54.6872]),
          zoom: 15
        })
      });
    </script>
  </body>
</html>

Leave a Comment