-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwroclaw.html
More file actions
161 lines (146 loc) · 5.66 KB
/
wroclaw.html
File metadata and controls
161 lines (146 loc) · 5.66 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
<!DOCTYPE html>
<html lang="pl">
<head>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2047748593355011"
crossorigin="anonymous"></script>
<meta charset="UTF-8" />
<title>Mieszkania Warszawa</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/maplibre-gl/dist/maplibre-gl.css" rel="stylesheet" />
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="stylesmap.css">
</head>
<body>
<div id="instruction" class="instruction-banner">
Kliknij na marker, aby zobaczyć szczegóły mieszkania
<button class="close-instruction" onclick="hideInstruction()">❌</button>
</div>
<div class="desktop-only">
<div id="map"></div>
<div class="legend-toggle" onclick="toggleLegend()">📌 Legenda</div>
<div class="legend" id="legend-box">
<strong>Legenda</strong>
<div><span class="color-box" style="background-color: #ff3333;"></span> Kawalerka</div>
<div><span class="color-box" style="background-color: #33cc33;"></span> 2-pokojowe</div>
<div><span class="color-box" style="background-color: #62c2ee;"></span> 3-pokojowe</div>
<div><span class="color-box" style="background-color: #cc61f7;"></span> 4-pokojowe</div>
<hr />
<a href="https://docs.google.com/forms/d/e/1FAIpQLSdOaZtgnFBLZXORA3AGpP86sUQpFay56juBhUSRO2p0mH5M2w/viewform?usp=dialog" target="_blank" class="form-link">Zaproponuj mieszkanie</a>
<hr />
<a href="https://docs.google.com/forms/d/e/1FAIpQLSeTUpVSojdV0jk18P1Ol2hMoEPMaJ0fhrJ1mfbbCGCnIy2p8Q/viewform?usp=dialog" target="_blank" class="form-link">Zgłoś problem z ogłoszeniem</a>
</div>
<div id="info-panel"></div>
</div>
<script>
const map = new maplibregl.Map({
container: "map",
style: "https://tiles.openfreemap.org/styles/bright",
center: [17.031925, 51.110002],
zoom: 13.5
});
function fetchFlats() {
fetch("https://opensheet.elk.sh/1f4gPSfyRkDU5stxd6htaVMh6Jm0Ex9jxG9mCVNOHPtA/mieszkaniawroclaw")
.then(res => res.json())
.then(data => {
const features = data.map(row => ({
type: "Feature",
geometry: {
type: "Point",
coordinates: [parseFloat(row.longitude), parseFloat(row.latitude)]
},
properties: {
title: row.title,
typ: row.typ,
opis: row.opis,
cena: row.cena,
image: row.image,
link: row.link
}
}));
const geojson = {
type: "FeatureCollection",
features: features
};
if (map.getSource("flats")) {
map.getSource("flats").setData(geojson);
} else {
map.addSource("flats", {
type: "geojson",
data: geojson
});
map.addLayer({
id: "flats-layer",
type: "circle",
source: "flats",
paint: {
"circle-radius": 8,
"circle-color": [
"match",
["get", "typ"],
"kawalerka", "#ff3333",
"2-pokojowe", "#33cc33",
"3-pokojowe", "#62c2ee",
"4-pokojowe", "#cc61f7",
"#999999"
],
"circle-stroke-color": "#ffffff",
"circle-stroke-width": 2
}
});
map.on("click", "flats-layer", (e) => {
const feature = e.features[0];
const panel = document.getElementById("info-panel");
panel.innerHTML = `
<h2 class="title">${feature.properties.title}</h2>
<img class="image" src="${feature.properties.image}" style="width: 100%; height: auto; margin-bottom: 10px;">
<p class="cena">Cena: ${feature.properties.cena} + opłaty</p>
<p class="opis">${feature.properties.opis}</p>
<a class="link" href="${feature.properties.link}" target="_blank">Zobacz Ofertę</a>
`;
panel.style.display = "block";
});
map.on("click", (e) => {
const features = map.queryRenderedFeatures(e.point, { layers: ["flats-layer"] });
if (features.length === 0) {
document.getElementById("info-panel").style.display = "none";
}
});
map.on("mouseenter", "flats-layer", () => {
map.getCanvas().style.cursor = "pointer";
});
map.on("mouseleave", "flats-layer", () => {
map.getCanvas().style.cursor = "";
});
}
});
}
map.on("load", () => {
fetchFlats();
setInterval(fetchFlats, 15000); // auto-aktualizacja co 15s
});
</script>
<script>
function toggleLegend() {
const legend = document.getElementById("legend-box");
legend.style.display = (legend.style.display === "block") ? "none" : "block";
}
</script>
<script>
function hideInstruction() {
const instruction = document.getElementById("instruction");
if (instruction) instruction.style.display = "none";
}
</script>
<div class="contact-panel" id="contact-panel">
<strong>Arkadiusz K.</strong><br>
<a href="mailto:taniemieszkaniedlastudenta@gmail.com">taniemieszkaniedlastudenta@gmail.com</a>
</div>
<script>
function toggleContact() {
const panel = document.getElementById("contact-panel");
panel.style.display = (panel.style.display === "block") ? "none" : "block";
}
</script>
</body>
</html>