-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
204 lines (176 loc) · 6.34 KB
/
Copy pathindex.html
File metadata and controls
204 lines (176 loc) · 6.34 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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<!DOCTYPE html>
<html>
<head>
<title>Graph Analytics</title>
<style type="text/css">
body {
margin:0;
}
#map {
height: 450px;
width: 100%;
}
button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
cursor: pointer;
width: 25%;
float: left;
}
.btn-btn-upload {
top:50px;
background-color: #FFFFFF; /* White */
border: 2px solid #555555; /* Black */
color: black;
}
.btn-btn-upload:hover {
background-color: #3e8e41;
}
.button:hover {
background-color: #3e8e41;
border: 2px solid #FFFFFF;
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
}
#map {
float: middle;
position:absolute;
left:25%;
top:7.5%;
width: 650px;
height: 500px;
margin: 5px;
border: 1px solid rgba(0, 0, 0, .2);
}
</style>
</head>
<script type="text/javascript" src="filereader.js"></script>
<script type="text/javascript" src="graphutil.js"></script>
<script src="graph.js"></script>
<body>
<button class="button" onclick="cluster()">Cluster</button>
<button class="button">Salesman</button>
<button class="button" onclick="overlay()">Travel</button>
<button class="button" onclick="save()">Save</button>
<div id="map"></div>
<script src="FileSaver.js"></script>
<script src="FileSaver.min.js"></script>
<script>
var dd,ds;
var map;
function initMap() {
var mapstart = {lat: 15.390649, lng: 73.878237};
var directionsDisplay = new google.maps.DirectionsRenderer;
var directionsService = new google.maps.DirectionsService;
dd=directionsDisplay;
ds=directionsService;
map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: mapstart,
mapTypeId: 'terrain'
});
// uncomment for directions display
directionsDisplay.setMap(map);
// Create an array of alphabetical characters used to label the markers.
//var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Add some markers to the map.
// Note: The code uses the JavaScript Array.prototype.map() method to
// create an array of markers based on a given "locations" array.
// The map() method here has nothing to do with the Google Maps API.
/*var markers = locations.map(function(location, i) {
return new google.maps.Marker({
position: location,
label: labels[i % labels.length]
});
});*/
// Add a marker clusterer to manage the markers.
//var markerCluster = new MarkerClusterer(map, markers,
//{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
map.addListener('click', function(e) {
placeMarkerAndPanTo(e.latLng, map);
});
}
// Adds a marker to the map and push to the array.
function placeMarkerAndPanTo(latLng, map) {
var marker = new google.maps.Marker({
position: latLng,
map: map
});
//map.panTo(latLng);
var value = marker.getPosition().toString().replace(/[()]/g, '').split(",");
//alert(value);
var number = locations.length+1;
var pushvalue = "'"+number+"':{'name':"+number+"','lat':"+value[0].slice(0,5)+", 'long':"+value[1].slice(1,6)+",'isClustered':false,'isClusterhead':false,'clusterNo':-1,'edges':[]}";
locations.push(pushvalue);
//console.log(locations);
var point={
"name":number+"",
"lat":value[0].slice(0,5),
"long":value[1].slice(1,6),
"isClustered":false,
"isClusterhead":false,
"clusterNo":-1,
"edges":[],
"marker":marker
};
points.push(point);
}
function createLine(p1,p2)
{
var route = [{lat: parseFloat(p1.lat), lng: parseFloat(p1.long)},{lat: parseFloat(p2.lat), lng: parseFloat(p2.long)}];
var polyline = new google.maps.Polyline({
path: route,
geodesic: true,
strokeColor: "#ff0000",
strokeOpacity: 0.6,
strokeWeight: 5
});
polyline.setMap(map);
}
function calculateAndDisplayRoute(p1,p2) {
var selectedMode = 'WALKING';
alert(p1.lat+","+p2.long);
ds.route({
origin: {lat: parseFloat(p1.lat), lng: parseFloat(p1.long)},
destination: {lat: parseFloat(p2.lat), lng: parseFloat(p2.long)},
// Note that Javascript allows us to access the constant
// using square brackets and a string value as its
// "property."
travelMode: google.maps.TravelMode[selectedMode]
}, function(response, status) {
if (status == 'OK') {
dd.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
});
}
//save file
function save() {
var textToSave = JSON.stringify(locations),
filename = 'file.txt',
//textToSave.replace(/\\/g, "");
blob = new Blob([textToSave], {type: "text/plain;charset=utf-8"});
saveAs(blob, filename);
}
var locations = []
function printLCL(){
console.log(locations);
}
</script>
<script src="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js">
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAD0SAXDhDL_OunUV2eOGovipUGtKSs8wk&callback=initMap">
</script>
<button class="btn-btn-upload" style="position:absolute; left:37.5%; top:85%">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="18" height="18" viewBox="0 0 32 32">
<path d="M14 18h4v-8h6l-8-8-8 8h6zM20 13.5v3.085l9.158 3.415-13.158 4.907-13.158-4.907 9.158-3.415v-3.085l-12 4.5v8l16 6 16-6v-8z"></path>
</svg> Upload</button>
</body>
</html>