mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-08-09 04:14:04 +00:00
48 lines
1.1 KiB
Markdown
48 lines
1.1 KiB
Markdown
---
|
|
layout: tutorial_frame
|
|
title: Quick Start
|
|
customMapContainer: "true"
|
|
---
|
|
<div id='map' style='width: 600px; height: 400px;'></div>
|
|
<script>
|
|
|
|
const map = L.map('map').setView([51.505, -0.09], 13);
|
|
|
|
const tiles = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
maxZoom: 19,
|
|
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
|
}).addTo(map);
|
|
|
|
const marker = L.marker([51.5, -0.09]).addTo(map)
|
|
.bindPopup('<b>Hello world!</b><br />I am a popup.').openPopup();
|
|
|
|
const circle = L.circle([51.508, -0.11], {
|
|
color: 'red',
|
|
fillColor: '#f03',
|
|
fillOpacity: 0.5,
|
|
radius: 500
|
|
}).addTo(map).bindPopup('I am a circle.');
|
|
|
|
const polygon = L.polygon([
|
|
[51.509, -0.08],
|
|
[51.503, -0.06],
|
|
[51.51, -0.047]
|
|
]).addTo(map).bindPopup('I am a polygon.');
|
|
|
|
|
|
const popup = L.popup()
|
|
.setLatLng([51.513, -0.09])
|
|
.setContent('I am a standalone popup.')
|
|
.openOn(map);
|
|
|
|
function onMapClick(e) {
|
|
popup
|
|
.setLatLng(e.latlng)
|
|
.setContent(`You clicked the map at ${e.latlng.toString()}`)
|
|
.openOn(map);
|
|
}
|
|
|
|
map.on('click', onMapClick);
|
|
|
|
</script>
|