-
Notifications
You must be signed in to change notification settings - Fork 0
/
busStops.js
70 lines (67 loc) · 1.87 KB
/
busStops.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
var markersmain = [];
export function busStops(map, markers){
const iconBase =
"http://maps.google.com/mapfiles/kml/shapes/";
const icons = {
parking: {
icon: iconBase + "parking_lot_maps.png",
},
bus: {
icon: iconBase + "bus_maps.png",
},
gas: {
icon: iconBase + "gas_stations_maps.png",
},
compost: {
icon: iconBase + "shopping_maps.png",
},
dining: {
icon: iconBase + "dining_maps.png",
},
};
const busStops = [
{
position: {lat: 41.558832, lng: -72.661057},
title: "Vine Street / Washington Street",
type: "bus",
},
{
position: {lat: 41.560827, lng: -72.649256},
title: "Middletown Bus Terminal",
type: "bus",
},
{
position: {lat: 41.560586, lng: -72.655634},
title: "High Street / Washington Bus Stop",
type: "bus",
},
];
busStops.forEach(({position, title, type}, i) => {
const marker = new google.maps.Marker({
position: position,
icon: icons[type].icon,
});
marker.addListener("click", () => {
map.setZoom(17);
map.setCenter(marker.getPosition());
});
markersmain = markers;
marker.setMap(null)
document.getElementById("busBtn").addEventListener("click", hideMarkers);
document.getElementById("busBtn").addEventListener("click", setMarker);
function setMarker(){
map.setZoom(15)
map.setCenter({ lat: 41.556240724638144, lng: -72.65683037211356 })
marker.setMap(map)
}
markersmain.push(marker);
});
}
function setMapOnAll(map) {
for (let i = 0; i < markersmain.length; i++) {
markersmain[i].setMap(map);
}
}
function hideMarkers() {
setMapOnAll(null);
}