-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetData.js
More file actions
165 lines (124 loc) · 4.39 KB
/
getData.js
File metadata and controls
165 lines (124 loc) · 4.39 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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
var map=null;
function initMap() {
var origin_place_id = null;
var destination_place_id = null;
console.log("Hello there")
var travel_mode = google.maps.TravelMode.WALKING;
map = new google.maps.Map(document.getElementById('map'), {
mapTypeControl: false,
//center: {lat: -33.8688, lng: 151.2195},
zoom: 13
});
console.log("----------------------");
console.log(map);
// var infoWindow = new google.maps.InfoWindow({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.');
map.setCenter(pos);
var latLng = new google.maps.LatLng(pos.lat, pos.lng);
var marker = new google.maps.Marker({
position: latLng,
title: 'My Location',
map: map
//draggable: true
});
}, function() {
// handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
// handleLocationError(false, infoWindow, map.getCenter());
}
var directionsService = new google.maps.DirectionsService;
var directionsDisplay = new google.maps.DirectionsRenderer;
directionsDisplay.setMap(map);
}//function findLandmarks(keywords,lat,lon)
var lat =0.0;
var lon = 0.0;
function GetLocation(location) {
// alert(location.coords.latitude);
lat = location.coords.latitude;
lon = location.coords.longitude;
/* var map = new google.maps.Map(document.getElementById('mapholder'), {
mapTypeControl: false,
center: {lat: -33.8688, lng: 151.2195},
zoom: 13
});*/
console.log(lat+" "+lon);
/*lat = '38.932923';
lon = '-77.039296';*/
keywords = ["miami","museum","fort","beach","house", "gym", "dive"];
var keyMap ={};
for(var str in keywords)
{
keyMap[str.toString()] = true;
}
$.get("https://api.sandbox.amadeus.com/v1.2/points-of-interest/yapq-search-circle",
{
apikey: 'x8MR4S8BBwPtqrugkGfJJC4tRWBdqcn4',
latitude: lat,
longitude: lon,
radius:'200',
//city_name: '',
number_of_results: '20',
}, function(data, status)
{
//alert("Data: " + data + "\nStatus: " + status);
var pntsOfInterest = data['points_of_interest'];
var counter=0;
// var infowindow = new google.maps.InfoWindow();
var marker, i;
console.log("============================"+pntsOfInterest)
for(i=0; i<pntsOfInterest.length;i++)
{
//console.log(JSON.stringify(data));
var titleStr =[];
placeFound = false;
titleStr= pntsOfInterest[i].title.split(" ");
for(j =0;j<titleStr.length;j++)
{
// console.log("---------------");
// console.log(titleStr[j]);
if(keywords.indexOf(titleStr[j].toLowerCase() ) != -1) {
placeFound = true;
// marker = new google.maps.Marker({
// position: new google.maps.LatLng(pntsOfInterest[i][1], pntsOfInterest[i][2]),
// map: map });
// console.log("--------------------asasasdsdsd---------------");
// google.maps.event.addListener(marker, 'click', (function(marker, i) {
// return function() {
// // infowindow.setContent(pntsOfInterest[i][0]);
// // infowindow.open(map, marker);
// }})(marker, i));
break;
}
}
if(placeFound){
// alert(pntsOfInterest[i].location.latitude);
var latLng = new google.maps.LatLng(pntsOfInterest[i].location.latitude, pntsOfInterest[i].location.longitude);
var marker = new google.maps.Marker({
position: latLng,
title: pntsOfInterest[i].title,
map: map,
icon: "/zother/img/marker-pin-small.png"
//draggable: true
});
}
}
}
);
//alert(location.coords.longitude);
//alert(location.coords.accuracy);
}
function findLandmarks()
{
navigator.geolocation.getCurrentPosition(GetLocation);
//return data;
}