-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjv.js
More file actions
132 lines (77 loc) · 2.86 KB
/
jv.js
File metadata and controls
132 lines (77 loc) · 2.86 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
$(document).ready(function(){
$("#submit").click(function(){
$("#print").empty();
$.get("https://api.foursquare.com/v2/venues/search?client_id=SNQKKXSZ0HF3JE4YU2CMQ43A321ZLE4AXCBFCXYTQ1EJN2PU&client_secret=GVTUZ2P4R4N0DHZ4WSXSOY4KRSDQG4JOTFLB13SPATIYDOII&v=20160213&near=" + $("#ip").val() + "&query=" + $("#q").val() + "&limit=10", function(data){
for(i=0;i< data.response.venues.length;i++){
var place = {
lat : data.response.venues[i].location.lat,
lng : data.response.venues[i].location.lng
};
$("#print").append("<li class =search"+ i +">"+ data.response.venues[i].name+"</li>");
console.log(data.response);
(function(place) {
$(".search"+i).click(this, function(){
$("#map-canvas").css("opacity",1);
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
// Creates the map
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var mapOptions = {
zoom: 14,
center: pos
}
directionsDisplay.setMap(map);
}
var mapOptions = {
center: new google.maps.LatLng(place),
zoom: 18
};
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
console.log("pizza");
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
var marker1 = new google.maps.Marker({
map: map,
position: pos ,
title: 'Hello World!'
});
});
};
function calcRoute() {
var selectedMode = document.getElementById("mode").value;
var request = {
origin: pos,
destination: place,
// Note that Javascript allows us to access the constant
// using square brackets and a string value as its
// "property."
travelMode: google.maps.TravelMode[selectedMode]
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
var marker = new google.maps.Marker({
map: map,
position: place ,
title: 'Hello World!'
});
//console.log(data.response.venues[0].name);
});
})(place)
}
});
$("#clear").click(function(){
$("#print").empty();
$("#map-canvas").css("opacity",0);
});
});
});