OpenStreetMap and Leaflet.js

Snippets code to use OpenStreetMap and Leaflet.js
Share:
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

OpenStreetMap is a map of the world, created by people like you and free to use under an open license.

Leaflet is the leading open-source JavaScript library for mobile-friendly interactive maps.

<!-- Leaflet -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
     integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
     crossorigin=""/>

<!-- Make sure you put this AFTER Leaflet's CSS -->
 <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
     integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
     crossorigin=""></script>

 <div id="map"></div>

<style>
  #map { height: 260px; }
  .leaflet-popup-content {
    font-size:2em;
  }

    /*if you need map 100% height use this CSS code
   html, body, #map {
      height: 100%;
      width: 100%;
  }

  /*greyscale
  .leaflet-tile-pane {
  -webkit-filter: grayscale(100%);
  filter: grayscale(100%);
}*/

</style>

<script>
  var map = L.map('map', {
    //deactivate zoom control & function
  doubleClickZoom: false, 
  closePopupOnClick: false, 
  dragging: false, 
  zoomSnap: false, 
  zoomDelta: false, 
  trackResize: false,
  touchZoom: false,
  scrollWheelZoom: false,
    zoomControl:false,
});
  map.setView([48.17959297289091, 11.6342699968432788], 15);

  

  L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

  const redIcon = new L.Icon({
      iconUrl:
        "https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-red.png",
      shadowUrl:
        "https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",
      iconSize: [25, 41],
      iconAnchor: [12, 41],
      popupAnchor: [1, -34],
      shadowSize: [41, 41]
    });

L.marker([48.17959297289091, 11.634269996843278],{
  icon: redIcon,
  tileSize: 512,
  
}).addTo(map)
    .bindPopup('IWSB Innovative Wirtschafts- und Steuerberatung GmbH')
    .openPopup();

  /** https://codepen.io/mnunes/pen/RXQqXz **/

</script>

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Article

Anchor link to Oxygen Builder Tabs
JS code to create anchor link for Tabs component of Oxygen Builder
Change Video Playing Speed with Javascript
If you want to play html tag "video" slower 80%, you can use this code:
Accordion
Accordion code snippet
COMPLETE PACKAGE OF WEBSITE DESIGN & DEVELOPMENT
Digitalizer offers website design & development services for company profiles, online shops, event organizers, educational institutions or other fields. You don't need to think about domains, web hosting / servers, DNS, email, design, development, security and other technical issues. Just prepare your website content, we do the rest.
All website design & development packages include 1 year maintenance!
Free Consultation
Back to top
cross