-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage-the-tutors.php
59 lines (55 loc) · 1.74 KB
/
page-the-tutors.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
<?php get_header(); ?>
<div id="map"></div>
<script>
var map = L.map("map");
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
map.setView([0, 0,], 5);
var fg = L.featureGroup().addTo(map);
map.once('focus', function() { map.scrollWheelZoom.enable(); });
</script>
<main>
<div class="container">
<div class="row">
<div class="col-12 col-sm-12">
<h1 class="page-title"><?php echo \Tofino\Helpers\title(); ?></h1>
</div>
</div>
<?php
$posts = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'tutors'
));
if( $posts ): ?>
<div class="row">
<?php foreach( $posts as $post ):
setup_postdata( $post ); ?>
<div class="col-12 col-sm-6 col-md-4">
<?php get_template_part('templates/post-list'); ?>
</div>
<?php
if( have_rows('geoloc') ):
while ( have_rows('geoloc') ) : the_row();
$lat = get_sub_field('lat');
$lng = get_sub_field('lng');
endwhile;
endif; ?>
<script>
L.marker([<?php echo $lat; ?>, <?php echo $lng; ?>]).addTo(fg).bindPopup('<a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a>');
</script>
<?php endforeach; ?>
<script>
<?php if($count == 1) : ?>
map.setView(new L.LatLng(<?php echo $lat; ?>, <?php echo $lng; ?>), 6);
<?php else : ?>
setTimeout(function () {
map.fitBounds(fg.getBounds());
}, 100);
<?php endif; ?>
</script>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
</div>
</main>
<?php get_footer(); ?>