-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
executable file
·281 lines (234 loc) · 10.4 KB
/
index.php
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<?php
include('header.php');
?>
<div class="row" style="width:100%;">
<div class="head-wrap">
<h2>#POKEMONCHATTER HERE</h2>
<div style="padding-top:3px;">
<a href="https://twitter.com/share" class="twitter-share-button" data-text="POKEMONNNNN" data-via="lohud" data-hashtags="#pokemongo" data-size="small">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<div class="fb-like" data-href="http://data.lohud.com/embeds/pokemongo/" data-layout="button_count" data-action="like" data-show-faces="true" data-share="true" style="top:-3px;padding-bottom:5px;"></div>
</div>
<p>CHATTER HERE</p>
<p style="font-size:12px;">Right click on the map to add a marker. On mobile, tap and hold to add a marker.</p>
</div>
</div>
<div class="row" style="height:100vh;">
<div class="large-11 small-centered columns" id="map" style="margin-top:20px; margin-bottom:20px; height:75vh;">
</div>
</div>
<div id="myModal" class="reveal-modal" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
<h2>Success!</h2>
<p>Your submission has been recorded and saved.</p>
<p><a href="#" onclick="location.reload();">Refresh map</a></p>
<a class="close-reveal-modal">×</a>
</div>
<!-- Map time -->
<script type="text/javascript">
var map = new L.Map('map').setView([41.033986, -73.762910],12);
// Define the different layers and default layer
var defaultLayer = L.tileLayer.provider('HikeBike.HikeBike', {maxZoom:18}).addTo(map);
var baseLayers = {
'Default': L.tileLayer.provider('HikeBike.HikeBike'),
'Watercolor': L.tileLayer.provider('Stamen.Watercolor'),
};
var layerControl = new L.control.layers(baseLayers).addTo(map);
var popup = L.popup();
function onMapClick(e) {
var form = '<form class="row" id="inputform" enctype="multipart/form-data" class="well">'+
'<select id="type" name="type">'+
'<option id="type" name="type" value="" selected="yes">Select type</option>'+
'<option id="type" name="type" value="Gym">Gym</option>'+
'<option id="type" name="type" value="Pokemon">Pokemon</option>'+
'<option id="type" name="type" value="PokeStop">PokeStop</option>'+
'</select>'+
'<div class="large-6 columns" style="width:100%; padding:0px;" id="pokemon">'+
// '<label>Pokemon name'+
// '<input type="text" placeholder="" id="pokename">'+
// '</label>'+
'</div>'+
'<input style="display: none;" type="text" id="lat" name="lat" value="'+ e.latlng.lat.toFixed(6)+'" />'+
'<input style="display: none;" type="text" id="lng" name="lng" value="'+ e.latlng.lng.toFixed(6)+'" /><br><br>'+
'<div class="row">'+
'<div class="small-10 columns"><button type="button small radius" id="button" onclick="insertUser()" class="btn radius medium" style="color:#f2f2f2;">Submit</button></div>'+
'</div>'+
'</form>';
popup
.setLatLng(e.latlng)
.setContent(form)
.openOn(map);
var marker = new L.marker(e.latlng).addTo(map);
$('#type').change(function(){
var selection = $(this).val();
if (selection == 'Pokemon') {
$('#pokemon').append('<label>Pokemon name<input type="text" placeholder="" id="pokename"></label>')
} else {
$('#pokemon').empty();
}
})
}
map.on('contextmenu', onMapClick);
var gymmarker = L.markerClusterGroup({
maxClusterRadius: 60,
iconCreateFunction: function(cluster) {
var gymmarker = cluster.getAllChildMarkers();
var n = 0;
for (var i = 0; i < gymmarker.length; i++) {
n += gymmarker[i].number;
}
return new L.DivIcon({ html: '<div style="width: 30px; height: 30px; margin-left: 5px; margin-top: 5px; text-align: center; border-radius: 15px; font: 12px, Arial, Helvetica, sans-serif;background-clip: padding-box; border-radius: 20px; background-color:#E6A963; line-height: 30px;margin-left:-10px; margin-top:-10px;color:#f2f2f2;">' + cluster.getChildCount() + '</div>' });
},
polygonOptions: {
fillColor: '#E6A963',
color: '#E6A963',
weight: 2,
opacity: 0.75,
fillOpacity: 0.5
},
});
var pokemarker = L.markerClusterGroup({
maxClusterRadius: 120,
iconCreateFunction: function(cluster) {
var pokemarker = cluster.getAllChildMarkers();
var n = 0;
for (var i = 0; i < pokemarker.length; i++) {
n += pokemarker[i].number;
}
return new L.DivIcon({ html: '<div style="width: 30px; height: 30px; margin-left: 5px; margin-top: 5px; text-align: center; border-radius: 15px; font: 12px, Arial, Helvetica, sans-serif;background-clip: padding-box; border-radius: 20px; background-color:#DC4554; line-height: 30px;margin-left:-10px; margin-top:-10px;color:#f2f2f2;">' + cluster.getChildCount() + '</div>' });
},
polygonOptions: {
fillColor: '#DC4554',
color: '#DC4554',
weight: 2,
opacity: 0.75,
fillOpacity: 0.5
},
});
var stopmarkers = L.markerClusterGroup({
maxClusterRadius: 120,
iconCreateFunction: function(cluster) {
var stopmarkers = cluster.getAllChildMarkers();
var n = 0;
for (var i = 0; i < stopmarkers.length; i++) {
n += stopmarkers[i].number;
}
return new L.DivIcon({ html: '<div style="width: 30px; height: 30px; margin-left: 5px; margin-top: 5px; text-align: center; border-radius: 15px; font: 12px, Arial, Helvetica, sans-serif;background-clip: padding-box; border-radius: 20px; background-color:#8FCCE0; line-height: 30px;margin-left:-10px; margin-top:-10px;color:#f2f2f2;">' + cluster.getChildCount() + '</div>' });
},
polygonOptions: {
fillColor: '#8FCCE0',
color: '#8FCCE0',
weight: 2,
opacity: 0.75,
fillOpacity: 0.5
},
});
var shownLayer, polygon;
function removePolygon() {
if (shownLayer) {
shownLayer.setOpacity(1);
shownLayer = null;
}
if (polygon) {
map.removeLayer(polygon);
polygon = null;
}
};
gymmarker.on('clustermouseover', function (a) {
removePolygon();
a.layer.setOpacity(0.2);
shownLayer = a.layer;
polygon = L.polygon(a.layer.getConvexHull());
map.addLayer(polygon);
});
gymmarker.on('clustermouseout', removePolygon);
pokemarker.on('clustermouseover', function (a) {
removePolygon();
a.layer.setOpacity(0.2);
shownLayer = a.layer;
polygon = L.polygon(a.layer.getConvexHull());
map.addLayer(polygon);
});
pokemarker.on('clustermouseout', removePolygon);
stopmarkers.on('clustermouseover', function (a) {
removePolygon();
a.layer.setOpacity(0.2);
shownLayer = a.layer;
polygon = L.polygon(a.layer.getConvexHull());
map.addLayer(polygon);
});
stopmarkers.on('clustermouseout', removePolygon);
map.on('zoomend', removePolygon);
var gymlist = [];
var pokelist = [];
var stoplist = [];
$.getJSON('entries.json', function(data){
myItems = data;
for (var i = 0; i < myItems.length; i++) {
var gymicon = L.icon({
iconUrl: 'gym.png',
iconSize: [48, 48],
});
var stopicon = L.icon({
iconUrl: 'stop.png',
iconSize: [58, 58],
});
var pokemonicon = L.icon({
iconUrl: 'pokemon.png',
iconSize: [48, 48],
});
var a = myItems[i];
if (a.Active === "Yes" && a.Type === "Gym") {
var type = a.Type;
var marker = L.marker(L.latLng(a.Lat, a.Lng), { type: type, icon: gymicon });
marker.bindPopup(type);
gymlist.push(marker);
gymmarker.addLayers(gymlist);
map.addLayer(gymmarker);
} else if (a.Active === "Yes" && a.Type === "Pokemon") {
var type = a.Type;
var pokemon = a.Pokemon;
var marker = L.marker(L.latLng(a.Lat, a.Lng), { type: type, icon:pokemonicon });
marker.bindPopup(
"Pokemon: "+pokemon);
pokelist.push(marker);
pokemarker.addLayers(pokelist);
map.addLayer(pokemarker);
} else if (a.Active === "Yes" && a.Type === "PokeStop") {
var type = a.Type;
var marker = L.marker(L.latLng(a.Lat, a.Lng), { type: type, icon:stopicon });
marker.bindPopup(type);
stoplist.push(marker);
stopmarkers.addLayers(stoplist);
map.addLayer(stopmarkers);
}
}
})
// Form submission
function insertUser() {
$("#loading-mask").show();
$("#loading").show();
var type = $("#type").val();
var lat = $("#lat").val();
var lng = $("#lng").val();
var pokemon = $("#pokename").val();
if (type.length == 0) {
alert("Select a type first!");
return false;
}
console.log(pokemon);
var dataString = '&type=' + type + '&pokemon=' + pokemon + '&lat=' + lat + '&lng=' + lng ;
// + '&pokemon=' + pokename
// console.log(dataString);
$.ajax({
type: "POST",
url: "insert.php",
data: dataString,
});
$('#myModal').foundation('reveal', 'open');
console.log('fired');
// return false;
}
</script>
<?php
include('footer.php');
?>