Displays Open Street Map with Leaflet

I used Open Street Map. Following is my personal note.

CSS

<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />

JavaScript

const L = require( 'leaflet' )

const element = document.getElementById( 'map' );
const lat = '25.1234'
const lng = '123.456'

const map = L.map( element ).setView( [ lat, lng ], 16 )

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

L.marker( [ lat, lng ] ).addTo( map )

 


Leave a Reply

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