-
Notifications
You must be signed in to change notification settings - Fork 0
/
script-center.js
91 lines (73 loc) · 2.57 KB
/
script-center.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
let apiKey = AIzaSyB7LGFloeOgHCn9B6_w0hSfiY5vpErgYhI;
// let directionService = new google.maps.DirectionService();
function initMap() {
var myLatlng = {
lat: 40.8136,
lng: -96.7026
};
var map = new google.maps.Map(document.getElementById('map'), {
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
position: google.maps.ControlPosition.TOP_LEFT,
mapTypeIds: ['roadmap', 'coordinate', 'satellite', 'hybrid', 'terrain', 'traffic']
},
trafficViewControl: true,
trafficViewControlOptions: {
position: google.maps.ControlPosition.RIGHT_CENTER
},
fullscreenControl: true,
fullscreenControlOptions: {
position: google.maps.ControlPosition.RIGHT_CENTER
},
zoom: 15,
center: myLatlng
});
let POINTS = lat + ',' + lng;
console.log(POINTS);
// // Get Place
// let placeId = 'https://roads.googleapis.com/v1/nearestRoads?points=' + POINTS + '&key=' + apiKey + '';
// // Nearest Roads
// let NEAREST_ROAD_URL = 'https://roads.googleapis.com/v1/nearestRoads?' +
// 'points=' + POINTS + '&key=' + apiKey + '&placeid=' + placeId + '';
google.maps.event.addListener(map, "center_changed", function() {
var center = this.getCenter();
var latitude = center.lat();
var longitude = center.lng();
// let road = NEAREST_ROAD_URL;
console.log("current latitude is: " + latitude);
console.log("current longitude is: " + longitude);
// LatLng
document.getElementById("lat").innerHTML = latitude;
document.getElementById("lng").innerHTML = longitude;
// Speed Limit Guess
//document.getElementById("").innerHTML = null;
// Speed Limit Guess
//document.getElementById("nearest-road").innerHTML = road;
});
// directionService.route({
// origin: myLatlng,
// destination: myLatlng,
// travelMode: google.maps.DirectionsTravelMode.DRIVING
// }, function (response, status) {
// if (status == google.maps.DirectionStatus.OK) {
// let homeMarker = new google.maps.Marker({
// position: response.routes[0].legs[0].start_location,
// map: map,
// title: "Location",
// icon: Image,
// shadow: shadow
// });
// } else {
// let homeMarker = new google.maps.Marker({
// position: myLatlng,
// map: map,
// title: "Location",
// icon: Image,
// shadow: shadow
// });
// }
// });
}
function closestRoad(map) {
}