Map: drop the North America coverage note; tiles.neiam.org is worldwide

5e3d6e5 · gmorell · 2026-11-24 05:45

13 files +16 -37
Message
{commit_body(@commit)}

Files changed

modified assets/js/photo_map.js
+1 −1
@@ -263,7 +263,7 @@ export default {
263 263 } else if (points.length > 1) {
264 264 this.map.fitBounds(points.map(p => [p.lat, p.lon]), {padding: [40, 40], maxZoom: 15})
265 265 } else {
266 − this.map.setView([39.5, -98.35], 3) // nothing yet: North America, where the tiles are
266 + this.map.setView([30, 0], 2) // nothing yet: the whole world
267 267 }
268 268 // fitBounds fires moveend itself, but setView to the current view does not.
269 269 if (this.el.dataset.boundsEvent) this.sendBounds()
modified lib/cartosnap_app/geocoder.ex
+3 −4
@@ -6,10 +6,9 @@ defmodule CartosnapApp.Geocoder do
6 6 for search-as-you-type; Nominatim's usage policy forbids autocomplete.
7 7
8 8 Two servers, asked in order, as the sibling apps do. The primary is our
9 − own, behind tiles.neiam.org: fast, but its index covers North America
10 − only. When it errors or finds nothing, komoot's public instance is asked:
11 − worldwide, but slower and offered on a fair-use basis, which the caller
12 − respects by debouncing keystrokes. Set with
9 + own, behind tiles.neiam.org, worldwide like its tiles. When it errors
10 + or finds nothing, komoot's public instance is asked: slower, and offered
11 + on a fair-use basis, which the caller respects by debouncing keystrokes. Set with
13 12 `config :cartosnap_app, :geocoder, base_url: ..., fallback_url: ...`
14 13 (`PHOTON_URL` / `PHOTON_FALLBACK_URL`; an empty fallback turns it off).
15 14
modified lib/cartosnap_app_web/components/photo_map.ex
+7 −29
@@ -21,14 +21,11 @@ defmodule CartosnapAppWeb.Components.PhotoMap do
21 21 Tiles come from our own OSM tile server (tiles.neiam.org), which renders
22 22 one style per app theme, so the map follows the theme instead of being a
23 23 bright rectangle in a dark page. Two limits come with it, both from the
24 − server:
24 + server: it only serves pages whose Referer it allowlists (`*.neiam.org`
25 + covers cs.neiam.org). It covers the whole world.
25 26
26 − * it only serves pages whose Referer it allowlists, and
27 − * it only has North America. Elsewhere, tiles are blank rather than
28 − missing, so the map says so instead of looking broken.
29 −
30 − Configure with `config :cartosnap_app, :map, tile_url: ..., styles: ...,
31 − coverage: ...`; `{style}` in the URL is replaced per theme.
27 + Configure with `config :cartosnap_app, :map, tile_url: ..., styles: ...`;
28 + `{style}` in the URL is replaced per theme.
32 29 """
33 30
34 31 use Phoenix.Component
@@ -54,9 +51,6 @@ defmodule CartosnapAppWeb.Components.PhotoMap do
54 51 "default" => "grayscale"
55 52 }
56 53
57 − # {min_lat, min_lon, max_lat, max_lon} the tiles actually cover.
58 − @default_coverage {5.0, -170.0, 84.0, -50.0}
59 −
60 54 attr :id, :string, required: true
61 55 attr :points, :list, required: true, doc: "from `points/1`"
62 56
@@ -93,14 +87,12 @@ defmodule CartosnapAppWeb.Components.PhotoMap do
93 87 attr :label, :string, default: "Map of photos"
94 88 attr :class, :any, default: "h-80", doc: "sizing for the map's frame"
95 89 attr :rounded, :boolean, default: true
96 − attr :coverage_note, :boolean, default: true
97 90
98 91 def photo_map(assigns) do
99 92 assigns =
100 93 assigns
101 94 |> assign(:tile_url, config(:tile_url, @default_tile_url))
102 95 |> assign(:styles, config(:styles, @default_styles))
103 − |> assign(:outside_coverage, Enum.count(assigns.points, &(!covered?(&1))))
104 96
105 97 ~H"""
106 98 <%!-- The size lives on this wrapper, never on the map: the map is
@@ -140,13 +132,6 @@ defmodule CartosnapAppWeb.Components.PhotoMap do
140 132 {@empty_label}
141 133 </span>
142 134 </div>
143 − <div
144 − :if={@coverage_note and @outside_coverage > 0}
145 − id={"#{@id}-coverage"}
146 − class="pointer-events-none absolute bottom-2 left-2 z-[500] rounded-full bg-base-100/90 px-2.5 py-1 text-[11px] text-warning shadow"
147 − >
148 − Map detail covers North America only
149 − </div>
150 135 </div>
151 136 """
152 137 end
@@ -190,23 +175,16 @@ defmodule CartosnapAppWeb.Components.PhotoMap do
190 175 defp lon_within?(lon, w, e), do: lon >= w or lon <= e
191 176
192 177 @doc """
193 − Where the tiles come from: the URL template with `{style}` in it, the tile
194 − style per app theme, and the `{min_lat, min_lon, max_lat, max_lon}` they
195 − cover.
178 + Where the tiles come from: the URL template with `{style}` in it, and the
179 + tile style per app theme.
196 180 """
197 181 def tiles do
198 182 %{
199 183 url: config(:tile_url, @default_tile_url),
200 − styles: config(:styles, @default_styles),
201 − coverage: config(:coverage, @default_coverage)
184 + styles: config(:styles, @default_styles)
202 185 }
203 186 end
204 187
205 − defp covered?(%{lat: lat, lon: lon}) do
206 − {min_lat, min_lon, max_lat, max_lon} = config(:coverage, @default_coverage)
207 − lat >= min_lat and lat <= max_lat and lon >= min_lon and lon <= max_lon
208 − end
209 −
210 188 defp config(key, default) do
211 189 :cartosnap_app |> Application.get_env(:map, []) |> Keyword.get(key, default)
212 190 end
modified test/cartosnap_app_web/live/map_live_test.exs
+5 −3
@@ -38,9 +38,11 @@ defmodule CartosnapAppWeb.MapLiveTest do
38 38 refute has_element?(view, "#map-panel-photos [data-photo-id='#{seattle.id}']")
39 39 end
40 40
41 − test "notes photos outside the tiles' coverage", %{conn: conn, scope: scope} do
42 − _paris = photo_fixture(scope, lat: 48.85, lon: 2.35)
41 + test "photos anywhere in the world are mapped, with no coverage caveat",
42 + %{conn: conn, scope: scope} do
43 + paris = photo_fixture(scope, lat: 48.85, lon: 2.35)
43 44 {:ok, view, _html} = live(conn, ~p"/map")
44 − assert has_element?(view, "#photos-map-coverage")
45 + assert render(element(view, "#photos-map")) =~ paris.id
46 + refute render(view) =~ "North America"
45 47 end
46 48 end

Parents: 505dc9b