2023-05-15 19:30:18 +00:00
|
|
|
@extends('template.'.config('settings.template').'.content.master')
|
2023-05-15 19:57:14 +00:00
|
|
|
@section('head')
|
|
|
|
<title>Home | {{config('settings.name')}}</title>
|
|
|
|
<style>
|
|
|
|
#map {
|
2023-05-16 11:42:14 +00:00
|
|
|
height: 80vh;
|
2023-05-15 19:57:14 +00:00
|
|
|
width: 100%;
|
2023-05-18 17:14:55 +00:00
|
|
|
}
|
|
|
|
.address + .address{
|
|
|
|
margin-top: .5rem;
|
|
|
|
}
|
|
|
|
#marker-window{
|
|
|
|
min-width: 100px;
|
2023-05-15 19:57:14 +00:00
|
|
|
}
|
2023-05-18 17:44:25 +00:00
|
|
|
#contents {
|
|
|
|
scrollbar-color: #aaa #f5f5f5;
|
|
|
|
}
|
|
|
|
|
|
|
|
#contents::-webkit-scrollbar {
|
|
|
|
width: 8px;
|
2023-05-26 04:39:15 +00:00
|
|
|
border-radius: 10px;
|
2023-05-18 17:44:25 +00:00
|
|
|
background-color: #f5f5f5;
|
|
|
|
}
|
|
|
|
|
|
|
|
#contents::-webkit-scrollbar-thumb {
|
2023-05-26 04:39:15 +00:00
|
|
|
border-radius: 10px;
|
2023-05-18 17:44:25 +00:00
|
|
|
background-color: #aaa;
|
|
|
|
}
|
|
|
|
|
|
|
|
#contents::-webkit-scrollbar-thumb:hover {
|
2023-05-26 04:39:15 +00:00
|
|
|
background-color: #888;
|
2023-05-18 17:44:25 +00:00
|
|
|
}
|
2023-05-30 15:25:00 +00:00
|
|
|
|
|
|
|
.address{
|
|
|
|
cursor: pointer;
|
|
|
|
transition: all .2s;
|
|
|
|
}
|
|
|
|
.address:hover{
|
|
|
|
background: #eee;
|
|
|
|
}
|
2023-05-15 19:57:14 +00:00
|
|
|
</style>
|
|
|
|
@stop
|
2023-05-15 19:30:18 +00:00
|
|
|
@section('content')
|
2023-05-18 17:14:55 +00:00
|
|
|
<div class="container py-5">
|
2023-06-08 14:22:12 +00:00
|
|
|
<div class="row mb-5 mt-3">
|
|
|
|
<div class="col-12">
|
|
|
|
<h1>{{config('settings.name')}}</h1>
|
|
|
|
<p class="mt-3">{{config('settings.description')}}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-05-18 17:14:55 +00:00
|
|
|
<div class="row mb-3">
|
|
|
|
<div id="filters" class="col-12 col-md rounded-end">
|
|
|
|
<div class="d-flex">
|
2023-05-30 15:25:00 +00:00
|
|
|
<div id="filters">
|
|
|
|
<div class="dropdown me-2 d-none">
|
|
|
|
<button class="btn btn-primary dropdown-toggle btn-sm" style="color: #212529; background: #e9ecef; border: 1px solid #ced4da;" type="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
|
|
|
$filter <span class="caret"></span>
|
|
|
|
</button>
|
|
|
|
<ul class="dropdown-menu checkbox-menu allow-focus p-2" id="options">
|
|
|
|
<li>
|
|
|
|
<label>
|
|
|
|
<input class="check-filter" type="checkbox" value="1"> $option
|
|
|
|
</label>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-05-23 05:02:35 +00:00
|
|
|
<div style="width: 350px;">
|
|
|
|
<input type="text" class="form-control form-control-sm" id="ort" placeholder="Ort"/>
|
2023-05-18 17:14:55 +00:00
|
|
|
</div>
|
2023-05-23 05:02:35 +00:00
|
|
|
<div style="width: 250px;" class="input-group ms-2">
|
2023-05-18 17:14:55 +00:00
|
|
|
<input type="text" class="form-control form-control-sm" id="search-input" placeholder="Freitext-Suche">
|
|
|
|
<span class="input-group-text" id="search-button">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-search" viewBox="0 0 16 16">
|
|
|
|
<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/>
|
|
|
|
</svg>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-12 col-md-auto pe-0 d-flex align-items-end">
|
2023-05-18 18:55:47 +00:00
|
|
|
<p class="text-end text-muted small m-0 p-0"><span id="count-items-displayed">0</span> results</p>
|
2023-05-16 11:42:14 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
2023-06-08 14:06:52 +00:00
|
|
|
|
2023-06-08 14:12:47 +00:00
|
|
|
<div class="col-12 col-md-8 g-0 ps-md-3 order-md-last">
|
2023-06-08 14:06:52 +00:00
|
|
|
<div id="map"></div>
|
|
|
|
<div id="marker-window" class="d-none">
|
|
|
|
<h6 id="firstHeading" class="firstHeading">$title</h6>
|
|
|
|
<div id="bodyContent">
|
|
|
|
<img class="img-fluid rounded" data-src="$image" alt="">
|
|
|
|
|
|
|
|
<p>$description</p>
|
|
|
|
<a data-href="$path" style="outline: none;">Details</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-12 col-md-4 overflow-auto mt-3 mt-md-0" style="height: 80vh;" id="contents">
|
2023-06-08 14:22:12 +00:00
|
|
|
<div class="card d-none address shadow-sm ">
|
2023-05-16 21:31:39 +00:00
|
|
|
<div class="card-body">
|
|
|
|
<div class="row">
|
2023-06-06 20:57:08 +00:00
|
|
|
<div class="col-12 col-md-5">
|
|
|
|
<img class="img-fluid rounded" data-src="$image" alt="">
|
2023-05-26 04:39:15 +00:00
|
|
|
</div>
|
2023-06-06 20:57:08 +00:00
|
|
|
<div class="col-12 col-md-7">
|
|
|
|
<h3 class="fs-6 mt-2">$title</h3>
|
|
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
|
2023-05-16 11:42:14 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-05-16 21:31:39 +00:00
|
|
|
</div>
|
2023-05-16 11:42:14 +00:00
|
|
|
</div>
|
2023-06-06 20:57:08 +00:00
|
|
|
|
2023-05-16 11:42:14 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-05-18 17:14:55 +00:00
|
|
|
<script src="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js"></script>
|
2023-05-16 21:31:39 +00:00
|
|
|
<script>
|
2023-06-08 17:51:07 +00:00
|
|
|
const contentUrl = "{{url('/types/'.$_type.'/contents')}}";
|
|
|
|
const locationField = "{{$_location_field}}";
|
2023-05-26 04:39:15 +00:00
|
|
|
//const filterFields = ['categoria'];
|
2023-05-15 18:45:13 +00:00
|
|
|
</script>
|
2023-05-18 17:14:55 +00:00
|
|
|
<script>
|
2023-05-30 15:25:00 +00:00
|
|
|
function initMap() {
|
|
|
|
function createInfowindowElement(item){
|
|
|
|
let infowindowElement = $("#marker-window").clone();
|
|
|
|
infowindowElement.html(infowindowElement.html().replace('$title', item.title));
|
|
|
|
infowindowElement.html(infowindowElement.html().replace('$description', item.description ?? ''));
|
|
|
|
infowindowElement.html(infowindowElement.html().replace('data-href="$path"', 'href="' + item.path + '"'));
|
|
|
|
infowindowElement.removeClass('d-none');
|
|
|
|
return infowindowElement[0].outerHTML;
|
|
|
|
}
|
|
|
|
|
|
|
|
let map = new google.maps.Map(document.getElementById("map"), {
|
|
|
|
streetViewControl: false,
|
|
|
|
mapTypeControl: false,
|
|
|
|
fullscreenControl: false,
|
|
|
|
});
|
2023-05-26 04:39:15 +00:00
|
|
|
|
2023-05-30 15:25:00 +00:00
|
|
|
let currentItems = [];
|
2023-05-26 04:39:15 +00:00
|
|
|
|
2023-05-23 05:02:35 +00:00
|
|
|
$.get(contentUrl).done(function (contents) {
|
2023-05-26 04:39:15 +00:00
|
|
|
let items = contents["contents"];
|
|
|
|
if (items != undefined) {
|
|
|
|
locationItems = items.filter(function (item) { return item[locationField].lat !== '' && item[locationField].lng !== '' });
|
2023-05-30 15:25:00 +00:00
|
|
|
currentItems = locationItems;
|
|
|
|
loadCurrentItems();
|
|
|
|
}
|
|
|
|
});
|
2023-05-18 17:14:55 +00:00
|
|
|
|
2023-05-30 15:25:00 +00:00
|
|
|
let markerCluster;
|
|
|
|
|
|
|
|
function loadCurrentItems() {
|
|
|
|
$("#count-items-displayed").text(currentItems.length);
|
|
|
|
if(markerCluster != undefined) markerCluster.clearMarkers();
|
|
|
|
if (currentItems.length > 0) {
|
|
|
|
let openInfoWindow = null;
|
|
|
|
|
|
|
|
currentItems = currentItems.map(function (item) {
|
2023-06-06 12:10:35 +00:00
|
|
|
if(item.location == undefined) item.location = {};
|
2023-05-30 15:25:00 +00:00
|
|
|
item.location.lat = parseFloat(item[locationField].lat);
|
|
|
|
item.location.lng = parseFloat(item[locationField].lng);
|
|
|
|
let marker = new google.maps.Marker({
|
|
|
|
position: { lat: item.location.lat, lng: item.location.lng },
|
|
|
|
map: map,
|
|
|
|
title: item.title,
|
|
|
|
optimized: false,
|
2023-05-18 17:14:55 +00:00
|
|
|
});
|
2023-05-30 15:25:00 +00:00
|
|
|
let infowindowElement = createInfowindowElement(item);
|
|
|
|
let infowindow = new google.maps.InfoWindow({ content: infowindowElement });
|
|
|
|
marker.addListener('click', function () {
|
|
|
|
if (openInfoWindow) openInfoWindow.close();
|
|
|
|
infowindow.open({ anchor: marker, map });
|
|
|
|
openInfoWindow = infowindow;
|
|
|
|
});
|
|
|
|
item.marker = marker;
|
|
|
|
return item;
|
2023-05-23 05:02:35 +00:00
|
|
|
});
|
2023-05-30 15:25:00 +00:00
|
|
|
|
|
|
|
let markers = currentItems.map(item => item.marker);
|
|
|
|
|
|
|
|
markerCluster = new MarkerClusterer(map, markers);
|
|
|
|
markerCluster.setStyles([{
|
2023-06-06 20:57:08 +00:00
|
|
|
url: '/template/cluster.png',
|
2023-05-30 15:25:00 +00:00
|
|
|
height: 40,
|
|
|
|
width: 40,
|
|
|
|
textSize: 14,
|
|
|
|
backgroundPosition: '0 0',
|
|
|
|
iconAnchor: [26, 53],
|
|
|
|
textColor: '#ffffff'
|
|
|
|
}]);
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
clearFocus();
|
|
|
|
showVisibleMarkers();
|
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const locationElementTemplate = $("#contents").children().first();
|
|
|
|
locationElementTemplate.remove();
|
|
|
|
|
|
|
|
function showVisibleMarkers() {
|
|
|
|
|
|
|
|
let showedItems = currentItems.filter(function (item) {
|
|
|
|
return map.getBounds().contains(item.marker.getPosition());
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#count-items-displayed").text(showedItems.length);
|
|
|
|
|
|
|
|
$("#contents").empty();
|
|
|
|
showedItems.forEach(function (item) {
|
|
|
|
let locationElement = locationElementTemplate.clone();
|
|
|
|
locationElement.html(locationElement.html().replace('$title', item.title));
|
|
|
|
locationElement.html(locationElement.html().replace('data-src="$image"', 'src="' + item.image + '"'));
|
|
|
|
locationElement.html(locationElement.html().replace('data-href="$path"', 'href="' + item.path + '"'));
|
|
|
|
locationElement.removeClass('d-none');
|
|
|
|
locationElement.on('click', function () {
|
|
|
|
map.setZoom(12);
|
|
|
|
map.setCenter(item.marker.getPosition());
|
|
|
|
showVisibleMarkers();
|
|
|
|
google.maps.event.trigger(item.marker, 'click');
|
|
|
|
});
|
|
|
|
$("#contents").append(locationElement);
|
|
|
|
});
|
2023-05-18 17:14:55 +00:00
|
|
|
|
2023-05-30 15:25:00 +00:00
|
|
|
showedItems = currentItems;
|
|
|
|
}
|
2023-05-18 17:14:55 +00:00
|
|
|
|
2023-05-30 15:25:00 +00:00
|
|
|
google.maps.event.addListener(map, 'dragend', showVisibleMarkers);
|
|
|
|
google.maps.event.addListener(map, 'zoom_changed', showVisibleMarkers);
|
2023-05-18 17:14:55 +00:00
|
|
|
|
2023-05-30 15:25:00 +00:00
|
|
|
$("#search-input").on("keyup", function(event) {
|
|
|
|
if (event.key === "Enter") $("#search-button").click();
|
|
|
|
});
|
|
|
|
$("#search-button").on("click", function () {
|
|
|
|
$("#contents").html("");
|
|
|
|
let value = $("#search-input").val();
|
|
|
|
currentItems = locationItems.filter(function (item) {
|
|
|
|
return item.title.toLowerCase().includes(value.toLowerCase());
|
|
|
|
});
|
|
|
|
loadCurrentItems();
|
|
|
|
});
|
2023-05-18 17:14:55 +00:00
|
|
|
|
2023-05-30 15:25:00 +00:00
|
|
|
function setLocationFocus(address){
|
|
|
|
new google.maps.Geocoder().geocode({ 'address': address }, function(results, status) {
|
|
|
|
if (status === google.maps.GeocoderStatus.OK) {
|
|
|
|
map.setCenter(results[0].geometry.location);
|
|
|
|
map.fitBounds(results[0].geometry.viewport);
|
|
|
|
} else {
|
|
|
|
console.warn('Geocode não obteve sucesso devido a: ' + status);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearFocus(){
|
|
|
|
let markers = currentItems.map(item => item.marker);
|
|
|
|
if(currentItems.length == 1) {
|
|
|
|
map.setZoom(12);
|
|
|
|
map.setCenter(markers[0].getPosition());
|
|
|
|
}else{
|
|
|
|
let bounds = new google.maps.LatLngBounds();
|
|
|
|
markers.forEach(function(marker){
|
|
|
|
bounds.extend(marker.getPosition());
|
|
|
|
});
|
|
|
|
map.fitBounds(bounds);
|
|
|
|
}
|
|
|
|
}
|
2023-05-23 05:02:35 +00:00
|
|
|
|
2023-05-30 15:25:00 +00:00
|
|
|
$('#ort').on("change", function(){
|
|
|
|
if($(this).val() === "") clearFocus();
|
|
|
|
});
|
2023-05-23 05:02:35 +00:00
|
|
|
|
2023-05-30 15:25:00 +00:00
|
|
|
let locationInput = $('#ort')[0];
|
|
|
|
let autocomplete = new google.maps.places.Autocomplete(locationInput, {"types": ["country", "route", "street_address", "locality"], "componentRestrictions": {"country": ["de","se","at","nl","br"]}});
|
|
|
|
autocomplete.addListener("place_changed", function () {
|
|
|
|
let place = autocomplete.getPlace();
|
|
|
|
let address = place.formatted_address;
|
|
|
|
if (!place.geometry) {
|
|
|
|
let inputText = locationInput.value;
|
|
|
|
let autocompleteService = new google.maps.places.AutocompleteService();
|
|
|
|
autocompleteService.getPlacePredictions({ input: inputText, componentRestrictions: { country: ["de", "se", "at", "nl", "br"] } }, function (predictions, status) {
|
|
|
|
if (status === google.maps.places.PlacesServiceStatus.OK && predictions && predictions.length > 0) {
|
|
|
|
let firstPrediction = predictions[0];
|
|
|
|
address = firstPrediction.description;
|
|
|
|
locationInput.value = address;
|
|
|
|
setLocationFocus(address);
|
2023-05-18 17:14:55 +00:00
|
|
|
}
|
2023-05-30 15:25:00 +00:00
|
|
|
});
|
|
|
|
} else setLocationFocus(address);
|
2023-05-18 17:14:55 +00:00
|
|
|
});
|
2023-05-30 15:25:00 +00:00
|
|
|
|
2023-05-18 17:14:55 +00:00
|
|
|
}
|
|
|
|
</script>
|
2023-05-23 05:02:35 +00:00
|
|
|
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAKGJCCKvmWZl-L5bBF0uS5BWf0gN4ZkpI&libraries=places&callback=initMap"></script>
|
2023-05-15 19:30:18 +00:00
|
|
|
@stop
|