-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\View\Components; | ||
|
||
use Closure; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\View\Component; | ||
|
||
class EventsMap extends Component | ||
{ | ||
/** | ||
* Create a new component instance. | ||
*/ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Get the view / contents that represent the component. | ||
*/ | ||
public function render(): View|Closure|string | ||
{ | ||
return view('components.events-map'); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
@once | ||
@push('scripts') | ||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" | ||
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="" /> | ||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" | ||
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script> | ||
<script> | ||
L.Control.Watermark = L.Control.extend({ | ||
onAdd: function(map) { | ||
var html = L.DomUtil.create('div'); | ||
html.innerHTML = ''; | ||
var expandButton = L.DomUtil.create('button', 'EventsMap-control-expand', html); | ||
var img = L.DomUtil.create('img', 'leaflet-control-watermark', expandButton); | ||
img.src = '/img/expand_content_24dp_FILL0_wght400_GRAD0_opsz24.svg'; | ||
L.DomEvent.on(expandButton, 'click', function(evt) { | ||
console.log("click expand", evt); | ||
evt.stopPropagation(); | ||
map.getContainer().classList.toggle('is-expanded'); | ||
// Invalidate size after css anim has finished. | ||
setTimeout(() => { | ||
map.invalidateSize({ | ||
pan: false | ||
}); | ||
}, 250); | ||
}); | ||
return html; | ||
}, | ||
onRemove: function(map) { | ||
// Nothing to do here | ||
}, | ||
}); | ||
L.control.watermark = function(opts) { | ||
return new L.Control.Watermark(opts); | ||
} | ||
class EventsMap { | ||
mapContainer = null; | ||
constructor(mapContainer) { | ||
this.mapContainer = mapContainer; | ||
console.log('EventsMap.constructor:', this.mapContainer); | ||
this.initMap(); | ||
} | ||
initMap() { | ||
console.log('EventsMap.initMap:', this.mapContainer); | ||
// Init in Jönköping | ||
let map = L.map(this.mapContainer).setView([59.1, 14.5], 6); | ||
window.map = map; | ||
console.log('window.map now available', window.map); | ||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | ||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OSM</a>' | ||
}).addTo(map); | ||
L.control.watermark({ | ||
position: 'topright' | ||
}).addTo(map); | ||
// map.on("click", function(evt) { | ||
// console.log("click expand", evt); | ||
// evt.stopPropagation(); | ||
// map.getContainer().classList.toggle('is-expanded'); | ||
// map.invalidateSize(); | ||
// }); | ||
// L.marker([51.5, -0.09]).addTo(map) | ||
// .bindPopup('A pretty CSS3 popup.<br> Easily customizable.') | ||
// .openPopup(); | ||
} | ||
} | ||
document.addEventListener('DOMContentLoaded', function() { | ||
let mapContainers = document.querySelectorAll('.EventsMap'); | ||
mapContainers.forEach(element => { | ||
console.log('element:', element); | ||
new EventsMap(element); | ||
}); | ||
// var map = L.map('EventsMap').setView([51.505, -0.09], 13); | ||
// L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | ||
// attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>' | ||
// }).addTo(map); | ||
// L.marker([51.5, -0.09]).addTo(map) | ||
// .bindPopup('A pretty CSS3 popup.<br> Easily customizable.') | ||
// .openPopup(); | ||
}); | ||
</script> | ||
@endpush | ||
|
||
@push('styles') | ||
<style> | ||
.EventsMap { | ||
height: 200px; | ||
background-color: antiquewhite; | ||
transition: height 0.25s ease-in-out; | ||
} | ||
.EventsMap.is-expanded { | ||
height: 70vh; | ||
} | ||
.EventsMap-control-expand { | ||
line-height: 1; | ||
margin: 0; | ||
padding: 2px; | ||
cursor: pointer; | ||
} | ||
.EventsMap-control-expand img { | ||
display: block; | ||
} | ||
</style> | ||
@endpush | ||
@endonce | ||
|
||
<div> | ||
<p>Karta.</p> | ||
<div class="EventsMap">Laddar karta...</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
|
||
@section('content') | ||
|
||
<x-events-map /> | ||
|
||
<x-text-tv-box /> | ||
|
||
<x-latest-events-box /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters