fix(regions): keep map labels of nearby regions apart
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 11m19s
ci / test (pull_request) Successful in 13m11s
ci / build (pull_request) Successful in 18m31s
ci / image (pull_request) Successful in 5m52s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 11m19s
ci / test (pull_request) Successful in 13m11s
ci / build (pull_request) Successful in 18m31s
ci / image (pull_request) Successful in 5m52s
Regions a few kilometres apart drew their labels on top of each other. As on the landing page, a label now runs to the right of its point, or to the left where the right side would cover another pin or leave the map; a pin with room on neither side shows only its dot and reveals its name on hover. Placement reruns while zooming and panning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
d91d600c90
commit
401a361422
3 files changed
+74
-1
No files matched your search
Vendored
+14
-1
@@ -20,6 +20,12 @@
|
||||
<input name="latitude" data-number data-nullable data-location-field="latitude">
|
||||
<input name="longitude" data-number data-nullable data-location-field="longitude">
|
||||
</div></form>
|
||||
<div id="near-map" data-region-map="edit" data-region-items="#near" data-map-server="stub" data-touch-hint="t" data-scroll-hint="{key} s" data-ctrl-key="Ctrl" hidden style="width:300px;height:200px;position:relative"></div>
|
||||
<table><tbody id="near">
|
||||
<tr data-lat="50" data-lon="8" data-name="Nuremberg" data-live="1"><td></td></tr>
|
||||
<tr data-lat="50.05" data-lon="8.5" data-name="Bamberg" data-live="1"><td></td></tr>
|
||||
<tr data-lat="55" data-lon="19" data-name="Gdansk" data-live="1"><td></td></tr>
|
||||
</tbody></table>
|
||||
<pre id="out"></pre>
|
||||
<script>
|
||||
const sent = [];
|
||||
@@ -35,11 +41,13 @@ window.maplibregl = {
|
||||
fitBounds(b) { this.bounds = b.points; }
|
||||
jumpTo(o) { this.center = o.center; }
|
||||
setStyle(s) { this.style = s; }
|
||||
// 10 px per degree, 8°E 50°N at the middle of the box.
|
||||
project({ lng, lat }) { return { x: 100 + (lng - 0) * 10, y: 100 - (lat - 50) * 10 }; }
|
||||
},
|
||||
Marker: class {
|
||||
constructor(o) { this.el = o.element; }
|
||||
setLngLat(p) { this.at = p; this.el.dataset.at = p.join(","); return this; }
|
||||
getLngLat() { return this.at; }
|
||||
getLngLat() { return { lng: this.at[0], lat: this.at[1] }; }
|
||||
addTo(map) { map.container.append(this.el); return this; }
|
||||
},
|
||||
NavigationControl: class {},
|
||||
@@ -100,6 +108,11 @@ window.maplibregl = {
|
||||
click(1, 2);
|
||||
check("closed row falls back to create form", create.elements.latitude.value, "1");
|
||||
|
||||
const near = maps[2];
|
||||
near.fire("load");
|
||||
const placement = () => [...near.container.querySelectorAll(".region-pin")].map((p) => [p.title, p.parentElement.classList.contains("is-flipped") ? "left" : p.parentElement.classList.contains("is-compact") ? "dot" : "right"]);
|
||||
check("close labels make room", placement(), [["Nuremberg", "dot"], ["Bamberg", "right"], ["Gdansk", "left"]]);
|
||||
|
||||
document.getElementById("out").textContent = out.join("\n");
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user