-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
114 lines (96 loc) · 8.09 KB
/
test.js
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
var map, infoWindow;
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: { lat: 32.8800604, lng: -117.2340135 },
zoom: 6
});
infoWindow = new google.maps.InfoWindow;
//markers
var geoloc = [0, 0]
var position = { lat: geoloc[0], lng: geoloc[1] }
var marker = new google.maps.Marker({
position: position,
map: 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);
}, 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);
}
var query = "hiking"
var searchObjectNameLocationAndPhotoID = []
$.ajax({
url: "https://maps.googleapis.com/maps/api/place/textsearch/json?query=" + query + "&location=32.7157380,-117.1610840&radius=50000&key=AIzaSyBSmftseE9huym0ariNTCamMnQmMZYaDYw"
}).done(function(response) {
var items = response.results;
console.log(items)
for (let value of items) {
var attachToPin={};
var lat = value.geometry.location.lat
var lng = value.geometry.location.lng
console.log(lat, lng);
var photoID = value.photos && value.photos[0].photo_reference
var name = value.name
var placeID = value.place_id
$.ajax({
url: "https://maps.googleapis.com/maps/api/place/details/json?placeid=" + placeID + "&key=AIzaSyBSmftseE9huym0ariNTCamMnQmMZYaDYw"
}).done(function(response) {
var description = response.result.reviews;
console.log(description);
console.log(response);
attachToPin = {
description: description[0].text
}
searchObjectNameLocationAndPhotoID.push(attachToPin)
})
}
console.log(searchObjectNameLocationAndPhotoID);
// return searchObjectNameLocationAndPhotoID
})
/*
var nameArray = ["Miner's Ridge Loop Trail", "Mission Trails-Kwaay Paay Peak Hike", "Blue Sky Ecological Reserve", "Three Sister Falls", "Annie's Canyon Trail", "Lake Jennings", "Shepherd Canyon", "Iron Mountain Trail Head", "Lake Calavera Hiking Trail", "Del Dios Gorge", "Ho Chi Minh Trail", "El Capitan Preserve", "Torrey Pines State Reserve", "Tecolote Canyon Natural Park", "Elfin Forest Recreational Reserve", "Crest Canyon Park", "Black Mountain Open Space Park", "Mt. Gower County Preserve", "Calavera Lake", "Mission Trails Regional Park"];
var photoIDArray = ["CmRaAAAAueLo-cy3BDZi6Fsi1puGYP_scGVQzNP6D_odyhLYVX6Dr7hrN8zSA8TiaD7pqTkvff6AH8_VPnEudrKl75f8riw4AomsJL6kaqrhRYtjpYhzP0Cn71r5MYBtERWlQJL_EhBRKxx9-kYsjUeTjsOz4J04GhRhNPq0b4aRq8xnu2xQwtgnRRkA7Q","CmRaAAAAXVjpP7FH529XBTaXCzMRvFbD2k3V_nN04sgV0b3RlUExVq6EDTa1_9qM0E2j_rJubdQg4Lloor5aPqzaUYSKNHscjeItmf2vBkm5g8dBXfOVfAxiLItX1jbyCKnMvwJsEhCVTZuRFHR8DYCgosE29yxiGhQ6nXcCiH5UdioPW_Ymmx0Ie0qyXw","CmRaAAAAo-0aF17sJPx634J9fuUx3bunoyn9tj3rata3f8qFRC67BFLArUEelTH4uayG09i8CByC8pUHU57gX6afURN3ECSsaWHn9LcFyfCf2rBbGsKaPvQ7tVcnWo-uRwkNN37jEhDUDftmsp7hK3i-pitvc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0A","CmRaAAAAwGRz3wxjJYjN7xQeEDp3R9X9Ilm7XE3czWjbVRYYlCMRNNQlM2GTiDo6EcpO90voByaYrly4teUj7pfdr7ZAg33UV58vKkTqXWgE2K65t5V6LB8GJPi3sTjZwXfExJ80EhAIPdwP_LWKjXSJC8nPAZApGhT5NdOBRzaR-Og7v5C5mCLlnR8zzQ","CmRaAAAAtkYTDAHIkivWL01O8mHQMllqiBEr927T1b5HSV-9uthMO6uHytPT1KLKgCQ-xvW_Jb3NqT6Irbsy-lRv4Y-a1nIkWT-YH_q3KLIpxwXyvxYeGbO4DwRHYkl-yWO2nfH9EhDOUjF5jj45UlntadO3ibubGhTGsDDna8luzzK--AlgZheYUmbCpQ","CmRaAAAANX-YJzEYar7ULmIhgaIOy9IiMsbNs1KCRXogDne_KpWND76BE2mGBL7LYTuPHOFvjziWpoDdTp__Jm5zazFCXGHeiMAixA9fDHsk9FJdVQqWIPBe6UIcqdKN7rNVXaI8EhAcTvcnwQYehJhwFuiZxYm7GhQQxm2FlQwcvdzKTZX9xOMjrPcUuQ","CmRaAAAAJaMBXOidY3SDtco73f_k9FnE-cNzhpkQG-QisNc1nDPu48bAi8hZ-wb2gjI2UJVefrWX1klFI9kh4ri_SIMVTJI8ngDijQNutbhle19-VwpiimU2IlqvZDwaXHe8IOspEhAk7r1z5BFak53Mje0iSJvZGhRSVavV6jKbhz56MCIPbGRro5CpXA","CmRaAAAAot3IhVO8-ZeeRq9Mg6EEEnM6UdCAXovpntQ06ceIbPyDmmYQqfM0hoTMVeCJU70HcicFNi_Aa7pVFB7w0jSpQREMIcFXWlFj-yuLUcosndRLS3N8KHFl90fSkKl1nL3DEhD4uJPhFM57MN_-OyqjSlGnGhSvCB2I32Lfg1y52simo0srBzye6w"]
var coordArray = [[32.9926742,-117.1159315],[32.840147,-117.036998],[33.0175881,-117.024536],[32.971054,-116.688326],[33.00490319999999,-117.2633145],[32.85377,-116.8844017],[32.8320906,-117.098583],[32.97749019999999,-116.9728484],[33.1692003,-117.2851578],[33.0536427,-117.1181574],[32.8861745,-117.2500071],[32.9132822,-116.8814731],[32.9216491,-117.2535292],[32.7755193,-117.1973509],[33.08112549999999,-117.1353297],[32.95853719999999,-117.2536494],[32.9829796,-117.1113107],[33.024839,-116.79692],[33.1708991,-117.2842292],[32.81795199999999,-117.05601]];
var searchObjectNameLocationAndPhotoID = []
console.log(nameArray.length)
console.log(photoIDArray.length)
console.log(coordArray.length)
for (i = 0; i < nameArray.length; i++) {
var attachToPin = {
name: nameArray[i],
lat: coordArray[i][0],
lng: coordArray[i][1],
photoID: photoIDArray[i]
}
searchObjectNameLocationAndPhotoID.push(attachToPin)
}
console.log(searchObjectNameLocationAndPhotoID)
$(document).ready(function(){
var container = $("<div>")
var testImage = $("<img>")
testImage.attr("src", "https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference="+ searchObjectNameLocationAndPhotoID[1].photoID + "&key=AIzaSyBSmftseE9huym0ariNTCamMnQmMZYaDYw" )
container.append(testImage)
$("#imageContainer").append(testImage)
})
*/