Skip to content

fix: comply with OpenStreetMap tile and Nominatim usage policies - #118

Open
marcopixel wants to merge 2 commits into
open-dxp:1.xfrom
marcopixel:fix/openstreetmap-usage-policy
Open

marcopixel wants to merge 2 commits into
open-dxp:1.xfrom
marcopixel:fix/openstreetmap-usage-policy

Conversation

@marcopixel

@marcopixel marcopixel commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Changes in this pull request

This PR addresses three related issues in the OpenStreetMap/Leaflet integration:

Tile requests: explicit Referrer-Policy

The L.tileLayer(...) configuration in geo/abstract.js did not specify a referrerPolicy. As a result, the Referer sent to the OSM tile server depended on the Referrer-Policy header configured by the web server serving the admin bundle, or on the browser default if no header was set.

This is easily visible inside the Admin UI by seeing this error message instead of map tiles:

image

The OSM wiki's Referer policy says tile requests without a Referer get blocked, and lists strict-origin-when-cross-origin as an accepted policy. Leaflet itself applied the same fix upstream in Leaflet/Leaflet#9897.

Fix:

Set referrerPolicy: 'strict-origin-when-cross-origin' explicitly on the tile layer. This ensures consistent behaviour regardless of the nginx/Apache configuration of the installation.

Geocoding: rate limiting and caching

The Nominatim usage policy limits clients to 1 request per second and requires applications to cache results.

Previously, geocode and reverseGeocode called sendRequest directly without any shared rate limiting or caching. This could result in multiple independent requests when several geo fields were present on a page. geopoint could also trigger reverse geocoding during every render and marker movement, while identical queries were never cached.

Fix:

  • Added opendxp.helpers.geocodingRequest as a shared geocoding helper.
  • Requests are queued and throttled to 1 request per second.
  • Results are cached by request URL to avoid duplicate requests.
  • geopoint.js now performs geocoding when the marker is clicked instead of during rendering.
  • Reverse geocoding after marker movement is debounced by 1 second.

Both geocode and reverseGeocode now use the shared helper.

Leaflet map re-initialization

Handling empty geocoding results also exposed an existing Leaflet issue when performing a new search.

If a map already exists on the container, calling L.map(...) again throws an error because Leaflet does not allow a second map instance to be initialized on the same container.

Fix:
getLeafletMap() now removes the existing this.leafletMap instance before creating a new map.

Prevent tile requests from being blocked due to restrictive Referrer-Policy by setting `strict-origin-when-cross-origin` on the tile layer.
This is the recommended way by OSM (https://wiki.openstreetmap.org/wiki/Referer).

Comply with OpenStreetMap Nominatim request limits by serializing and caching geocoding requests on the client.
- Handle empty geocoding responses in geo/abstract.js and return address_not_found.
- Ignore unsuccessful reverse geocoding responses instead of showing an undefined tooltip.
- Destroy the existing Leaflet map before rebuilding the container to prevent orphaned maps and tile layers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant