class Campus {
constructor(name, street, lat, lng, zoom = 15) {
this.name = name;
this.address = {
street,
geo: {
lat,
lng,
zoom,
},
};
}
getMapUrl() {
const lang = 'en_US';
const layers = 'map';
const zoom = this.address.geo.zoom;
const size = '650,350';
const marker = `${this.address.geo.lng},${this.address.geo.lat}`;
const icon = 'pm2rdm1';
return `https://static-maps.yandex.ru/1.x/?lang=${lang}&l=${layers}&z=${zoom}&size=${size}&pt=${marker},${icon}`;
}
}
const campuses = [];
campuses.push(new Campus('Campus Geel', 'Kleinhoefstraat 4', 51.16095, 4.96166));
campuses.push(new Campus('Campus Lier', 'Antwerpsestraat 99', 51.134006, 4.566427, 10));
campuses.push(new Campus('Campus Turnhout', 'Campus Blairon 800', 51.317004, 4.928719));
const turnhout = new Campus();
turnhout.name = 'Campus Vorselaar';
turnhout.address.street = 'Lepelstraat 2';
turnhout.address.geo.lat = 51.200987;
turnhout.address.geo.lng = 4.77261;
turnhout.address.geo.zoom = 16;
campuses.push(turnhout);
let cards = '';
campuses.forEach((campus) => {
console.log(campus);
cards += `
<div class="col-sm-12 col-md-6 col-lg-3">
<div class="card fluid">
<h3>${campus.name}</h3>
<p>${campus.address.street}</p>
<img src="${campus.getMapUrl()}" alt="${campus.name}" />
</div>
</div>`;
});
document.querySelector('.border-green').innerHTML = cards;
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