Skip to content

Commit b96f23d

Browse files
committed
Add a page for testing opacity works.
1 parent f40de07 commit b96f23d

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

debug/tests/opacity.html

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Leaflet debug page</title>
5+
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
7+
8+
<link rel="stylesheet" href="../../dist/leaflet.css" />
9+
<!--[if lte IE 8]><link rel="stylesheet" href="../../dist/leaflet.ie.css" /><![endif]-->
10+
11+
<link rel="stylesheet" href="../css/mobile.css" />
12+
<style>
13+
.mybox {
14+
background-color: red;
15+
}
16+
17+
</style>
18+
<script src="../leaflet-include.js"></script>
19+
</head>
20+
<body>
21+
22+
<div id="map"></div>
23+
24+
<script type="text/javascript">
25+
26+
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
27+
cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade',
28+
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution}),
29+
latlng = new L.LatLng(50.5, 30.51);
30+
31+
var map = new L.Map('map', {center: latlng, zoom: 15, layers: [cloudmade]});
32+
33+
//Create a marker, clicking it toggles opacity
34+
var marker = new L.Marker(latlng, { icon: new L.DivIcon({ className: 'mybox', iconSize: new L.Point(100,100), html: 'opaque. click to toggle' }) });
35+
map.addLayer(marker);
36+
37+
var visible = true;
38+
marker.on('click', function () {
39+
if (visible) {
40+
marker.setOpacity(0.3);
41+
marker._icon.innerHTML = 'transparent';
42+
} else {
43+
marker.setOpacity(1);
44+
marker._icon.innerHTML = 'opaque';
45+
}
46+
visible = !visible;
47+
});
48+
49+
var marker2 = new L.Marker(new L.LatLng(50.5, 30.52));
50+
map.addLayer(marker2);
51+
marker2.bindPopup('This is an amazing message. I shouldn\'t of deleted the Ipsum text');
52+
53+
54+
</script>
55+
</body>
56+
</html>

0 commit comments

Comments
 (0)