forked from HandsOnDataViz/searchable-map-template-csv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.js
74 lines (62 loc) · 1.89 KB
/
map.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
$(window).resize(function () {
var h = $(window).height(),
offsetTop = 125; // Calculate the top offset
$('#mapCanvas').css('height', (h - offsetTop));
}).resize();
$(function() {
SearchableMapLib.initialize({
filePath: 'data/chicago-flu-shot-locations-2019.csv',
fileType: 'csv',
recordName: 'flu shot location',
recordNamePlural: 'flu shot locations',
map_centroid: [41.85754, -87.66231],
defaultZoom: 11,
defaultRadius: 1610,
debug: false,
});
var autocomplete = new google.maps.places.Autocomplete(document.getElementById('search-address'));
var modalURL;
$('#btnSearch').click(function(){
// Temporary fix for map load issue: set show map as default.
if ($('#mapCanvas').is(":visible")){
SearchableMapLib.doSearch();
}
else {
$('#btnViewMode').html("<i class='fa fa-list'></i> List view");
$('#mapCanvas').show();
$('#listCanvas').hide();
SearchableMapLib.doSearch();
}
});
$(':checkbox').click(function(){
SearchableMapLib.doSearch();
});
$(':radio').click(function(){
SearchableMapLib.doSearch();
});
$('#btnViewMode').click(function(){
if ($('#mapCanvas').is(":visible")){
$('#btnViewMode').html("<i class='fa fa-map-marker'></i> Map view");
$('#listCanvas').show();
$('#mapCanvas').hide();
}
else {
$('#btnViewMode').html("<i class='fa fa-list'></i> List view");
$('#listCanvas').hide();
$('#mapCanvas').show();
}
});
$("#search-address, #search-name").keydown(function(e){
var key = e.keyCode ? e.keyCode : e.which;
if(key == 13) {
$('#btnSearch').click();
return false;
}
});
$(".close-btn").on('click', function() {
$.address.parameter('modal_id', null)
});
});
function formatAddress(prop) {
return prop["Street1"] + " " + prop["Street2"] + " " + prop["City"] + " " + prop["State"];
}