This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
forked from Outdooractive/leaflet-singleclick_0.7
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
52 lines (41 loc) · 1.6 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
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<head>
<title>Leaflet.singleclick example</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
#map { position: fixed; top: 0; left: 0; width: 100%; height: 100%; margin: 0; padding: 0; }
</style>
<link href="http://cdn.leafletjs.com/leaflet-1.0.0-b1/leaflet.css" rel="stylesheet" type="text/css" />
<script src="http://cdn.leafletjs.com/leaflet-1.0.0-b1/leaflet-src.js"></script>
</head>
<body>
<div id="map"></div>
<script type="text/javascript" src="singleclick.js"></script>
<script type="text/javascript">
var div = document.getElementById('map');
var map = L.map(div).setView([51.505, -0.09], 13);
var positron = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>'
}).addTo(map);
// test
map.options.singleClickTimeout = 250;
map.on('singleclick',function ( e ) {
console.log( 'map singleclick', e );
L.popup().setLatLng( e.latlng )
.setContent( '<p>Basemap <code>singleclick</code> at ' + e.latlng )
.openOn( map );
} );
var group = L.featureGroup().addTo(map);
var circle = L.circle([51.505, -0.09], 1000).addTo(group).on('singleclick', function(ev) {
console.log( 'circle singleclick', ev );
L.DomEvent.stop(ev);
L.popup().setLatLng( ev.latlng )
.setContent( '<p>Circle <code>singleclick</code> at ' + ev.latlng )
.openOn( map );
});
circle.options.singleClickTimeout = 250;
</script>
</body>
</html>