-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
45 lines (36 loc) · 1.47 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>singleclick example</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://leafletjs.com/dist/leaflet.css" />
<style type="text/css">#map { position: fixed; top: 0; left: 0; width: 100%; height: 100%; margin: 0; padding: 0; }</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript" src="http://leafletjs.com/dist/leaflet.js"></script>
<script type="text/javascript" src="singleclick.js"></script>
<script type="text/javascript">
// create a map
var div = document.createElement('div');
div.setAttribute('style','position:fixed;margin:0;padding:0;left:0;top:0;width:100%;height:100%;');
document.documentElement.appendChild(div);
var map = L.map(div).setView([51.505, -0.09], 13);
L.tileLayer('https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="http://mapbox.com">Mapbox</a>',
id: 'examples.map-i875mjb7'
}).addTo(map);
// test
map.on('singleclick',function ( e ) {
console.log( 'singleclick', e );
L.popup().setLatLng( e.latlng )
.setContent( '<p><code>singleclick</code> at ' + e.latlng )
.openOn( map );
} );
</script>
</body>
</html>