-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
66 lines (61 loc) · 2.31 KB
/
test.html
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
<script>
var map, infoWindow;
function initMap() {
map = new google.maps.Map(document.getElementById('map2'), {
center: {lat: -34.397, lng: 150.644},
zoom: 6
});
infoWindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
infoWindow.setPosition(pos);
infoWindow.setContent('Location found.');
infoWindow.open(map);
map.setCenter(pos);
service.nearbySearch({
location: pos,
radius: 500,
keyword: "pizza",
}, callback);
function callback(results, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
var websites = [];
for (var i = 0; i < results.length; i++) {
//createMarker(results[i]);
console.log(results[i]);
var temp = results[i].getName;
if(temp == ("Pizza Nova"))
websites.push("https://pizzanova.com/products/signature-pizzas/");
if(temp == ("Pizza Pizza"))
websites.push("https://order.pizzapizza.ca/PhoenixWEB/order/#cat/11080");
if(temp == ("Domino's Pizza"))
websites.push("https://order.pizzapizza.ca/PhoenixWEB/order/#cat/11080");
if(temp == ("Campus Pizza"))
websites.push("http://www.campuspizza.ca/?page=menu");
}
console.log(websites);
}
}
}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
}
function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: The Geolocation service failed.' :
'Error: Your browser doesn\'t support geolocation.');
infoWindow.open(map);
}
</script>
<div id="map2"></div>