Leaflet/debug/tests/opacity.html
Nathan Cahill 425fa13cb4 Various debug fixes (#4515)
* various debug fixes
* fix mixed spaces and tabs
2016-04-29 12:35:50 +03:00

59 lines
1.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Leaflet debug page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="../../dist/leaflet.css" />
<link rel="stylesheet" href="../css/mobile.css" />
<style>
.mybox {
background-color: red;
}
</style>
<script type="text/javascript" src="../../build/deps.js"></script>
<script src="../leaflet-include.js"></script>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
latlng = new L.LatLng(50.5, 30.51);
var map = new L.Map('map', {center: latlng, zoom: 15, layers: [osm]});
//Create a marker, clicking it toggles opacity
var opaqueIcon = new L.DivIcon({ className: 'mybox', iconSize: new L.Point(100,100), html: 'opaque. click to toggle' });
var transparentIcon = new L.DivIcon({ className: 'mybox', iconSize: new L.Point(100,100), html: 'transparent' });
var marker = new L.Marker(latlng, { icon: opaqueIcon });
map.addLayer(marker);
var visible = true;
marker.on('click', function () {
if (visible) {
marker.setOpacity(0.3);
marker.setIcon(transparentIcon)
} else {
marker.setOpacity(1);
marker.setIcon(opaqueIcon);
}
visible = !visible;
});
var marker2 = new L.Marker(new L.LatLng(50.5, 30.52));
map.addLayer(marker2);
marker2.bindPopup('This is an amazing message. I shouldn\'t of deleted the Ipsum text');
</script>
</body>
</html>