-
Notifications
You must be signed in to change notification settings - Fork 6
/
map2.html
106 lines (95 loc) · 2.56 KB
/
map2.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
<!DOCTYPE html>
<html>
<head>
<title>GP Clustering For Mopsi Dataset</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
#panel {
position: absolute;
top: 5px;
left: 50%;
margin-left: -180px;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script type = "text/javascript" language = "javascript">
// In the following example, markers appear when the user clicks on the map.
// The markers are stored in an array.
// The user can then click an option to hide, show or delete the markers.
var map;
var markers = [];
function initialize() {
var centerPoint = new google.maps.LatLng(62.5983,29.7439);
var mapOptions = {
zoom: 12,
center: centerPoint,
// mapTypeId: google.maps.MapTypeId.TERRAIN
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
loadLocations();
var marker = new google.maps.Marker({
position: centerPoint,
map: map
});
// markers.push(marker);
// setAllMap(map);
}
function loadLocations(){
alert("loading data..");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso.OpenTextFile("C:\\Users\\Titicaca\\Documents\\GitHub\\GP-Clustering\\dataset\\Mopsi.txt",1);
var s = "";
var count = 0;
while(!file.AtEndOfStream){
count++;
s = file.ReadLine();
var items = s.split("\t");
var x = parseFloat(items[0])/10000;
var y = parseFloat(items[1])/10000;
//alert(x + "," + y);
var location = new google.maps.LatLng(x,y);
var marker = new google.maps.Marker({
position: location,
map: map
});
markers.push(marker);
}
alert("data loaded..\n" + "Count:" + count);
}
// Sets the map on all markers in the array.
function setAllMap(map) {
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(map);
}
}
function showMarkers() {
setAllMap(map);
}
function showClusters() {
setAllMap(map);
}
function clearMarkers() {
setAllMap(null);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="panel">
<input onclick="showMarkers();" type=button value="Show All Markers">
<input onclick="showClusters();" type=button value="GPClustering">
<input onclick="clearMarkers();" type=button value="Clear Markers">
</div>
<div id="map-canvas"></div>
<p>Click on the map to add markers.</p>
</body>
</html>