Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
174 lines (162 loc) · 5.02 KB
/
Copy pathindex.html
File metadata and controls
174 lines (162 loc) · 5.02 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
163
164
165
166
167
168
169
170
171
172
173
174
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<meta name="viewport" content="width=device-width">
<style>
html, body {
width: 100%;
height: 100%;
}
#map, #mapContainter {
margin: 0;
padding: 0;
height: 95%;
width: 100%;
}
#location {
z-index: 5;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
width: 30%;
}
#love {
position:relative;
z-index: 5;
margin-left: auto;
margin-right: auto;
top: -20;
left: 0;
right: 0;
width: 75%;
text-align: center;
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
select,
textarea,
input {
font-size: 16px;
}
}
</style>
<meta charset="UTF-8">
<title>RR Beer Finder</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div style="height:100%; width:100%;">
<div id="divabove" style="width:100%">
<select id="location" style="position:absolute;" onChange="setCenter();">
<option value="MyLocation">My location</option>
<option value="NorCal" selected>NorCal</option>
<option value="Bay Area">Bay Area</option>
<option value="SoCal">SoCal</option>
<option value="Oregon">Oregon</option>
<option value="Colorado">Colorado</option>
<option value="Pennsylvania">Pennsylvania</option>
</select>
</div>
<div id="mapContainter">
<div id="map"></div>
<p id="love" class="love">Made with <i class="icon ion-heart"></i> by <a href="https://www.linkedin.com/in/tim-ferguson-01451892/">Tim Ferguson</a></p>
</div>
</div>
<script>
/*
If you've come to peek at the code, please know I threw this together very quickly. There are small bits of unused code and the coding practices aren't the best - this is just a hobby project I thought I'd share - Stay tuned and I will be updating it over the coming weeks, and cleaning up my code base.
*/
var globalData;
var labels;
var map;
var centers = {"NorCal": {lat: 38.441804, lng: -122.711617},"Bay Area": {lat:37.413001, lng:-121.962524}, "SoCal": {lat:33.817313, lng:-117.906398}, "Oregon":{lat:45.519443, lng: -122.678628}, "Colorado":{lat:39.734438, lng:-104.985611}, "Pennsylvania": {lat:40.091773, lng:-75.381653 }}
function setCenter() {
var loc = $('#location').val();
if(loc == "MyLocation")
{
navigator.geolocation.getCurrentPosition(function(position) {
map.setCenter({lat: position.coords.latitude, lng:position.coords.longitude});
map.setZoom(10);
},
function(){
map.setCenter(centers["NorCal"]);
map.setZoom(10);
});
}
map.setCenter(centers[loc]);
map.setZoom(10);
}
function initMap() {
var mothership = {lat: 38.441804, lng: -122.711617};
map = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
minZoom: 7,
center: mothership
});
var marker = new google.maps.Marker({
position: mothership,
map: map,
title: 'Russian River Brewing Company',
label: 'Russian River Brewing Company'
});
var getContent = function(data){
var addrCity = data.address + ', ' +data.city;
var nameAddrCity = data.name + '-' +addrCity;
return '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h1 id="firstHeading" class="firstHeading">'+data.name+'</h1>'+
'<div id="bodyContent">'+
'<p><b>Address:</b>'+ data.address +', '+ data.city+' '+
'</p>'+
'<br/>'+
'<p>Link: <a href="http://maps.apple.com/?q='+encodeURIComponent(addrCity)+'" >'+ nameAddrCity +' </a>'+
'</p>'+
'</div>'+
'</div>'
}
function handleMarkerClick(marker, index) {
if (typeof infowindow === 'undefined') {
infowindow = new google.maps.InfoWindow({});
}
var data = globalData[index]//helpful data
//create content with dynamic data
infowindow.setContent(getContent(data));
infowindow.open(marker.getMap(), marker);//modify as per your requirement
}
$.get( "/Locations", function( data ) {
globalData = data;
for(var i = 0; i < data.length; i ++)
{
var addrCity = data[i].address + ', ' +data[i].city;
var nameAddrCity = data[i].name + '-' +addrCity;
var marker = new google.maps.Marker({
position: {lat: data[i].lat, lng:data[i].lng},
map: map,
title: data[i].name,
clickable: true
//label: data[i].name
});
var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h1 id="firstHeading" class="firstHeading">'+data[i].name+'</h1>'+
'<div id="bodyContent">'+
'<p><b>Address:</b>'+ data[i].address +', '+ data[i].city+' '+
'</p>'+
'<br/>'+
'<p>Link: <a href="http://maps.apple.com/?q='+encodeURIComponent(addrCity)+'" >'+ nameAddrCity +' </a>'+
'</p>'+
'</div>'+
'</div>';
google.maps.event.addListener(marker, 'click', handleMarkerClick.bind(undefined, marker, i));
}
//alert( "Load was performed." );
});
}
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBHAjg4T55aMKSaAaXd4RfWUv6uOJyQKiQ&callback=initMap">
</script>
</body>
</html>