Display simple Marker on the Map

This tutorial shows how to add a default Marker to the map.

  1. Copy the following code, paste it into your favorite text editor, and save it as a .html file.

  2. Replace YOUR_MAPTILER_API_KEY_HERE with your actual MapTiler API key.

  3. The next is up to you. You can start the map in a different place by modifying the starting position and starting zoom, and you can change the look of the map to any of our styles, or yours, by updating the source URL. See what’s available here.

  4. To create a new marker using a Vector layer. The layer’s data source will be a feature set. Create a feature of type point at the Lng/Lat coordinates of the marker. Create a Style to load the marker image and finally added it to the current map using .addLayer() function. Download the marker image here

     const layer = new ol.layer.Vector({
     source: new ol.source.Vector({
         features: [
         new ol.Feature({
             geometry: new ol.geom.Point(ol.proj.fromLonLat([16.62662018, 49.2125578])),
     style: new ol.style.Style({
         image: new ol.style.Icon({
         anchor: [0.5, 1],
         crossOrigin: 'anonymous',
         src: 'https://docs.maptiler.com/openlayers/default-marker/marker-icon.png',