-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlab-overview.php
88 lines (76 loc) · 3.25 KB
/
lab-overview.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* Template Name: Lab-Übersicht
*/
get_header();
?>
<?php
while (have_posts()) :
the_post();
get_template_part('template-parts/header-alpaka', get_post_type());
?>
<section class="c-blog-list is-grid pt-5">
<?php
$args = array('post_type' => 'lab',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'lab-location',
'field' => 'slug',
'terms' => $community_id, // set in functions.php
'operator' => 'NOT IN', // this line excludes the community
),
)
);
$the_query = new WP_Query($args);
$pins = array(); ?>
<?php if ($the_query->have_posts()) : ?>
<div class="col-s fg c-event-map mb-5">
<div id="map" class="c-map"></div>
<noscript>Kein JavaScript? Hier sollte eine Karte mit der Event Location dargestellt werden.</noscript>
</div>
<ul class="">
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
<?php
array_push($pins, [
'coordinates' => [
get_field('event_lat'), get_field('event_lon')
],
'name' => get_the_title(),
'excerpt' => get_the_excerpt(),
'link' => get_permalink()
]);
get_template_part('template-parts/children', 'lab'); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
</ul>
<?php endif; ?>
</section>
<?php get_template_part('template-parts/partner', 'lab') ?>
<script>
var mymap = L.map('map').setView([51.163361, 10.447683], 6);
//https://api.mapbox.com/styles/v1/okfn/{id}/tiles/256/{z}/{x}/{y}?access_token={accessToken}
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
tileSize: 512,
maxZoom: 18,
zoomOffset: -1,
id: 'mapbox/streets-v11',
accessToken: 'pk.eyJ1Ijoib2tmZGUiLCJhIjoiY2syMzZjazFrMDZpejNtcW11Mm5pMnozNSJ9.6QaPMbeUg3k8fcVUmvvpxA'
}).addTo(mymap);
var customMarker = L.icon({
iconUrl: '<?php echo get_template_directory_uri(); ?>/images/events/Pin-x1.png',
iconRetinaUrl: '<?php echo get_template_directory_uri(); ?>/images/events/Pin-x2.png',
iconSize: [17, 23],
iconAnchor: [9, 22],
tooltipAnchor: [15, -10]
});
<?php foreach ($pins as $pin): ?>
L.marker(<?= json_encode($pin['coordinates']) ?>, {icon: customMarker})
.bindPopup('<h4 class="mt-0 mb-0"><?= $pin['name'] ?></h4><p><?= $pin['excerpt'] ?><p><a href="<?= $pin['link'] ?>">Zur Seite</a></p>')
.addTo(mymap)
<?php endforeach; ?>
</script>
<?php
endwhile;
get_footer();