UNPKG

leaflet-collapse-button

Version:
88 lines (71 loc) 2.48 kB
<html> <head> <title>Demo - Leaflet Collapse Button</title> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin=""/> <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script> <script src="../index.js"></script> <link rel="stylesheet" href="../index.css"> <style> #mapid { height: 360px; } .col-md-4 { width: 20%; } .col-md-8 { width: 80%; } .col-md-12 { width: 100%; } .hidden { display: none; } .row { float: left; width: 100%; display: flex; } .panel { background-color: grey; } </style> </head> <body> <div class="row"> <div id="mapid" class="col-md-8"></div> <div id="cards" class="col-md-4 panel"></div> </div> <script> var map = L.map('mapid').setView([41.96, 34.0106666], 13); L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', { maxZoom: 18, attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, ' + 'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>', id: 'mapbox/streets-v11', tileSize: 512, zoomOffset: -1 }).addTo(map); L.marker([41.96, 34.0106666]).addTo(map) .bindPopup("<b>Howdy partner!</b>").openPopup(); map.addControl(new L.Control.CollapseButton({ currentStatus: 1, position: 'topleft', title: 'Hide Panel', titleCancel: 'Show Panel', elementId: 'mapid', targetElementId: 'cards', hideClasses: 'col-md-12', showClasses: 'col-md-8', targetHideClasses: 'hidden', targetShowClasses: 'col-md-4' })); </script> </body> </html>