Repository navigation
Expand file tree
/
Copy pathmap.js
More file actions
145 lines (118 loc) · 4.48 KB
/
Copy pathmap.js
File metadata and controls
145 lines (118 loc) · 4.48 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
function initialize() {
var start = new google.maps.LatLng(0, 0)
var mapOptions = {
center: { lat: 46.8303, lng: 17.7340 },
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var iconMap = {
Camping: "campground",
Hotel: "lodging"
}
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var markers = [
{
"Name": "Aranypart Camping",
"Category": "Lodging",
"SubCategory": "Camping",
"Address": "Siófok, Szent László u. 185, 8600",
"Owner": "Kis Jakab",
"Ownership": "direct",
"Articles": ""
},
{
"Name": "Balatontourist Zala Kemping és Üdülőfalu",
"Category": "Lodging",
"SubCategory": "Camping",
"Address": "Keszthely, Entz Géza stny. 1, 8360",
"Owner": "Meszáros Lőrinc",
"Ownership": "direct",
"Articles": "https://24.hu/belfold/2017/04/12/meszaros-lorinc-cege-felvasarolta-a-balatoni-kemping-nagy-reszet/"
}
];
const lookUpAddress = 'https://maps.googleapis.com/maps/api/geocode/json?address='
function httpGet(url) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", url, false); // false for synchronous request
xmlHttp.send(null);
return xmlHttp.responseText;
}
markers.forEach(element => {
element.Geocode = JSON.parse(httpGet(lookUpAddress + element.Address));
});
markers.forEach(element => {
var marker = new google.maps.Marker({
position: element.Geocode.results["0"].geometry.location,
map: map,
title: element.Name,
icon: {
url: "icons/" + iconMap[element.SubCategory] + ".svg",
scaledSize: { height: 20, width: 20 }
}
});
});
/* getFileFromServer("owners.csv", function (text) {
if (text === null)
return
rows = text.split("\n");
var headers = rows[0].split("\t");
markers = [];
infoWindowContent = [];
for (i = 1; i < rows.length; i++) {
// row 0: ID of sample (title) 44563383.3.txt
// row 13: coordinates
//
var cols = rows[i].split("\t");
if (cols.length == 1)
continue;
var lat = cols[13].split(',')[0];
var lon = cols[13].split(',')[1];
var contentString = "<b>" + cols[0] + "</b><br>";
for (j = 1; j < cols.length; j++) {
if (cols[j] != "NA" && cols[j] != "na")
contentString = contentString + headers[j] + ":" + cols[j] + "<br>";
}
console.log(cols[2])
switch (cols[2]) {
case "water":
color = "80D0FF"
break;
case "soil":
color = "D0B060"
break;
default:
color = "E0E0E0"
}
markers.push([cols[0], lat, lon, color])
infoWindowContent.push(contentString);
}
var infoWindow = new google.maps.InfoWindow(), marker, i;
for (i = 0; i < markers.length; i++) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(markers[i][1], markers[i][2]),
map: map,
title: markers[i][0],
icon: new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|" + markers[i][3], new google.maps.Size(21, 34), new google.maps.Point(0, 0), new google.maps.Point(10, 34))
});
google.maps.event.addListener(marker, 'click', (function (marker, i) {
return function () {
infoWindow.setContent(infoWindowContent[i]);
infoWindow.open(map, marker);
}
})(marker, i));
}
}); */
}
google.maps.event.addDomListener(window, 'load', initialize);
/* function getFileFromServer(url, doneCallback) {
var xhr;
xhr = new XMLHttpRequest();
xhr.onreadystatechange = handleStateChange;
xhr.open("GET", url, true);
xhr.send();
function handleStateChange() {
if (xhr.readyState === 4) {
doneCallback(xhr.status == 200 ? xhr.responseText : null);
}
}
} */