forked from scrazyderyl/RestroomRadar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
66 lines (53 loc) · 1.44 KB
/
main.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
var map;
//Remove point of interest on the map
var mapStyle = [
{
featureType: "poi",
elementType: "labels",
stylers: [
{ visibility: "off" }
]
}
];
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: { lat: 40.4455452, lng: -79.9561952 },
zoom: 16,
styles: mapStyle
});
}
//After clicking the button you can click the map which will call the add bathroom with the location
function grabCurrentLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var currentLat = position.coords.latitude;
var currentLng = position.coords.longitude;
// Add a marker to the map at the current location coordinates
addBathroom({ lat: currentLat, lng: currentLng })
});
} else {
alert("Geolocation is not supported by this browser.");
}
}
//Load the form here and add the other information with location to db?
function addBathroom(location) {
title = "test"
createMarker(location, title)
}
function createMarker(location, title) {
var marker = new google.maps.Marker({
position: location,
content:title,
map: map
});
map.panTo(position);
}
function addInfoWindow(marker, title) {
var infoWindow = new google.maps.InfoWindow({
content: title
});
google.maps.event.addListener(marker, 'click', function () {
infoWindow.open(map, marker);
});
}
window.initMap = initMap;