mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	Give the everything example add/remove buttons
This commit is contained in:
		| @@ -19,6 +19,8 @@ | ||||
| <body> | ||||
|  | ||||
| 	<div id="map"></div> | ||||
| 	<button id="populate">Populate 1 marker</button> | ||||
| 	<button id="remove">Remove 1 marker</button> | ||||
| 	<span>Mouse over a cluster to see the bounds of its children and click a cluster to zoom to those bounds</span> | ||||
| 	<script type="text/javascript"> | ||||
|  | ||||
| @@ -87,6 +89,25 @@ | ||||
|  | ||||
| 		populate(); | ||||
| 		map.addLayer(markers); | ||||
|  | ||||
|  | ||||
| 		//Ugly add/remove code | ||||
| 		L.DomUtil.get('populate').onclick = function () { | ||||
| 			var bounds = map.getBounds(), | ||||
| 			southWest = bounds.getSouthWest(), | ||||
| 			northEast = bounds.getNorthEast(), | ||||
| 			lngSpan = northEast.lng - southWest.lng, | ||||
| 			latSpan = northEast.lat - southWest.lat; | ||||
| 			var m = new L.Marker(new L.LatLng( | ||||
| 					southWest.lat + latSpan * 0.5, | ||||
| 					southWest.lng + lngSpan * 0.5)); | ||||
| 			markersList.push(m); | ||||
| 			markers.addLayer(m); | ||||
| 		}; | ||||
| 		L.DomUtil.get('remove').onclick = function () { | ||||
| 			markers.removeLayer(markersList.pop()); | ||||
| 		}; | ||||
|  | ||||
| 	</script> | ||||
| </body> | ||||
| </html> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user