-
Notifications
You must be signed in to change notification settings - Fork 0
/
map-2.html
141 lines (120 loc) · 4.59 KB
/
map-2.html
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple Polylines</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
.gm-style-mtc {
display: none;
}
.gmnoprint a, .gmnoprint span, .gm-style-cc {
display: none!important;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
// Create map
function initialize() {
// Style map
var styles = [{"featureType":"water","elementType":"geometry","stylers":[{"color":"#1f2c32"}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#364d56"}]},{"featureType":"road","elementType":"geometry","stylers":[{"color":"#29768a"},{"lightness":-37}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#406d80"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#406d80"}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#3e606f"},{"weight":2},{"gamma":0.84}]},{"elementType":"labels.text.fill","stylers":[{"color":"#ffffff"}]},{"featureType":"administrative","elementType":"geometry","stylers":[{"weight":0.6},{"color":"#1a3541"}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#2c5a71"}]}];
var mapOptions = {
zoom: 3,
center: new google.maps.LatLng(39.798842, 32.308883),
styles: styles,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
// Create line from origin to current location
var coordinatesToCurrentLocation = [
new google.maps.LatLng(51.960208, 1.352738),
new google.maps.LatLng(50.930380, 1.474318),
new google.maps.LatLng(49.950855, -1.305223),
new google.maps.LatLng(49.155683, -5.882976),
new google.maps.LatLng(45.042499, -11.194866),
new google.maps.LatLng(35.835652, -10.491741),
new google.maps.LatLng(35.800017, -4.207561),
new google.maps.LatLng(38.289959, 10.074665),
new google.maps.LatLng(33.376437, 24.312946),
new google.maps.LatLng(31.940701, 31.552152),
new google.maps.LatLng(26.650021, 34.619125),
];
var toPath = new google.maps.Polyline({
path: coordinatesToCurrentLocation,
geodesic: true,
strokeColor: '#2BA6B3',
strokeOpacity: 0.8,
strokeWeight: 3
});
// Create line from current location to destination
var coordinatesToDestination = [
new google.maps.LatLng(26.650021, 34.619125),
new google.maps.LatLng(18.335969, 39.666852),
new google.maps.LatLng(12.798842, 43.308883),
new google.maps.LatLng(11.737444, 45.481323),
new google.maps.LatLng(13.800947, 53.903406),
new google.maps.LatLng(15.284129, 67.418516),
new google.maps.LatLng(16.752390, 70.716784),
new google.maps.LatLng(19.036442, 72.842421),
];
var fromPath = new google.maps.Polyline({
path: coordinatesToDestination,
geodesic: true,
strokeColor: '#f6db76',
strokeOpacity: 0.8,
strokeWeight: 3
});
// Create markers
var imageCurrent = {
url: 'http://chaosdigital.co.uk/kontainers-2016/assets/images/marker.png',
size: new google.maps.Size(30, 30),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(15, 15)
};
var imageFrom = {
url: 'http://chaosdigital.co.uk/kontainers-2016/assets/images/from-marker.png',
size: new google.maps.Size(20, 24),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(10, 24)
};
var imageTo = {
url: 'http://chaosdigital.co.uk/kontainers-2016/assets/images/to-marker.png',
size: new google.maps.Size(20, 24),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(10, 24)
};
var currentLatLng = {lat: 26.650021, lng:34.619125};
var fromLatLng = {lat: 51.960208, lng:1.352738};
var toLatLng = {lat: 19.036442, lng:72.842421};
var markerCurrent = new google.maps.Marker({
position: currentLatLng,
map: map,
icon:imageCurrent
});
var markerFrom = new google.maps.Marker({
position: fromLatLng,
map: map,
icon:imageFrom
});
var markerTo = new google.maps.Marker({
position: toLatLng,
map: map,
icon:imageTo
});
toPath.setMap(map);
fromPath.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>