-
Notifications
You must be signed in to change notification settings - Fork 0
/
LeafletTest1.html
74 lines (67 loc) · 2.28 KB
/
LeafletTest1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Leaflet Test 1 (Leaflet Quick Start Guide)</title>
<!-- Reference: https://leafletjs.com/examples/quick-start/ -->
<link rel="stylesheet" href="../resources/libs/leaflet/1.3.4/leaflet.css"/>
<script src="../resources/libs/leaflet/1.3.4/leaflet.js"></script>
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map = L.map("map").setView([39.9062, 116.3912], 13);
L.tileLayer('https://server.arcgisonline.com/arcgis/rest/services/world_imagery/mapserver/tile/{z}/{y}/{x}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 19,
id: 'world_imagery',
}).addTo(map);
{
var marker = L.marker([39.9062, 116.3912]).addTo(map);
var circle = L.circle([39.9062, 116.3912], {
color: 'red',
fillColor: '#f03',
fillOpacity: 0.5,
radius: 500
}).addTo(map);
var polygon = L.polygon([
[39.8962, 116.3812],
[39.8962, 116.4012],
[39.9162, 116.4012],
[39.9162, 116.3812]
]).addTo(map);
marker.bindPopup("<b>Hello world!</b><br>I am a popup.").openPopup();
circle.bindPopup("I am a circle.");
polygon.bindPopup("I am a polygon.");
}
{
var popup = L.popup()
.setLatLng([39.9262, 116.3912])
.setContent("I am a standalone popup.")
.openOn(map);
}
{
// function onMapClick(e) {
// alert("You clicked the map at " + e.latlng);
// }
// map.on("click", onMapClick);
}
{
var popup_ = L.popup();
function onMapClick(e) {
popup_.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(map);
}
map.on('click', onMapClick);
}
</script>
</body>
</html>