-
Notifications
You must be signed in to change notification settings - Fork 0
/
clubs.php
61 lines (48 loc) · 1.42 KB
/
clubs.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
<?php
require_once 'private_php/p_global.php';
require_once 'private_php/v_html_club.php';
require_once 'private_php/p_html_functions.php';
pageHeader('Clubs', ['map.js']);
$clubs = Club::loadAll();
$jsMapMarkers = '';
$minLat = 90;
$maxLat = -90;
$minLong = 180;
$maxLong = -180;
foreach ($clubs as $club) {
if ($club->hasMapCoordinates()) {
$lat = $club->venueLatitude();
$long = $club->venueLongitude();
if ($lat < $minLat) $minLat = $lat;
if ($lat > $maxLat) $maxLat = $lat;
if ($long < $minLong) $minLong = $long;
if ($long > $maxLong) $maxLong = $long;
$jsMapMarkers .= "
createMarker(map, $lat, $long, " . json_encode($club->urlName()) . ', '
. json_encode($club->name()) . ');';
}
}
?>
<div id="subNav">
<?php echo clubNavBar(); ?>
</div>
<div id="subBody">
<h2>Clubs</h2>
<script type="text/javascript">
document.write('<div id="map" style="width: 100%; height: 500px;"></div>');
function clubMap() {
var mapOptions = {
center: new google.maps.LatLng(<?php echo ($minLat + $maxLat) / 2; ?>, <?php echo ($minLong + $maxLong) / 2; ?>),
zoom: 10
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
var marker, bubble;
<?php echo $jsMapMarkers; ?>
}
</script>
<script id="mapScript" src="https://maps.googleapis.com/maps/api/js?key=<?php echo $GoogleMapKey; ?>&callback=clubMap"></script>
<p>Please select a club to view.</p>
</div>
<?php
pageFooter();
?>