-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
61 lines (49 loc) · 1.76 KB
/
Copy pathapp.js
File metadata and controls
61 lines (49 loc) · 1.76 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
'use strict'
let state = newState();
let utils = newUtils();
let handlers = newHandlers();
let myGeocoder;
let map;
//FOR CONTROL BUTTON
function CenterControl(controlDiv, map) {
// Set CSS for the control border.
let controlUI = document.createElement('div');
controlUI.style.backgroundColor = '#fff';
controlUI.style.border = '2px solid #fff';
controlUI.style.borderRadius = '3px';
controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)';
controlUI.style.cursor = 'pointer';
controlUI.style.marginBottom = '22px';
controlUI.style.textAlign = 'center';
controlUI.title = 'Click to calculate distance';
controlDiv.appendChild(controlUI);
// Set CSS for the control interior.
let controlText = document.createElement('div');
controlText.style.color = 'rgb(25,25,25)';
controlText.style.fontFamily = 'Roboto,Arial,sans-serif';
controlText.style.fontSize = '16px';
controlText.style.lineHeight = '38px';
controlText.style.paddingLeft = '5px';
controlText.style.paddingRight = '5px';
controlText.innerHTML = 'Calculate';
controlUI.appendChild(controlText);
controlUI.addEventListener('click', handlers.getDistance);
}
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
disableDefaultUI: false,
draggable: false,
maxZoom: 15,
minZoom: 15,
center: {lat: 50.0646501, lng: 19.9449799}
});
myGeocoder = new google.maps.Geocoder;
map.addListener('click', function(event) {
handlers.getAddress(myGeocoder, map, event.latLng);
});
let centerControlDiv = document.createElement('div');
let centerControl = new CenterControl(centerControlDiv, map);
centerControlDiv.index = 1;
map.controls[google.maps.ControlPosition.TOP_CENTER].push(centerControlDiv);
}