-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.php
More file actions
73 lines (59 loc) · 2.11 KB
/
Copy pathmap.php
File metadata and controls
73 lines (59 loc) · 2.11 KB
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
<?php require_once "includes/header.php"; ?>
<?php require_once "keys/keys.php";
if (!isset($_SESSION['access_token'])) {
header("Location: login.php");
}
?>
<section id="main_top">
<span id="slogan" class="display-2">AnimalShelterFinder</span>
<form class="main_top__form form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-primary my-2 my-sm-0" type="submit">Search</button>
</form>
</section>
<section id="main_map">
<?php
if (isset($_GET['address'])) {
// echo $_GET['address'];
// keys
require_once "keys/keys.php";
// send get request
require_once "includes/http_functions.php";
$address = $_GET['address'];
} else {
// todo show all shelters near user
}
?>
<div id="map"></div>
<script>
var map;
var geocoder;
var marker;
var pos;
function initMap() {
// use address to get lat & lng from geocoder
var address = "<?= $address; ?>";
geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': address}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
// alert(results[0].geometry.location);
//alert("<?//= $address; ?>//");
pos = results[0].geometry.location;
map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: pos
});
marker = new google.maps.Marker({
position: pos,
map: map,
// bouncing marker
animation: google.maps.Animation.BOUNCE
});
}
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=<?= $GMP_API_KEY; ?>&callback=initMap"
async defer></script>
</section>
<?php require_once "includes/footer.php"; ?>