Usage
Tile-Proxy-Endpoint
With this extension you can define a page in the TYPO3 backend as an endpoint for maps.
If the slug for your page is e.g. tile-proxy, the data can be retrieved from:
/tile-proxy/?provider=osm&z={z}&x={x}&y={y}
Arguments
provider
Currently only osm (OpenStreetMap) is supported, so the value must be osm.
z
zoom level (https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames)
x
x-tile coordinate (https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames)
y
y-tile coordinate (https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames)
s (optional, obsolete)
The subdomains (a, b, c) of the OSM tile servers are obsolete. The argument is still accepted to stay compatible with existing integrations, but it is ignored.
The values of z, x and y must address an existing tile (zoom level 0 to 19), otherwise you will receive error 1000. Such requests are never forwarded to OpenStreetMap.
If the tile must be loaded and is not cached, this request will be mapped to:
https://tile.openstreetmap.org/{z}/{x}/{y}.png
If OpenStreetMap is not reachable, an outdated tile from the cache is delivered if there is one, otherwise the error tile. In both cases the response is sent with a short caching time (60 seconds), so the tile is requested again soon.
The http referrer must be your own domain, localhost or configured in page settings or extension configuration. If these options do not offer enough flexibility, you can implement your own logic for verifying the referrer via a listener to the PSR-14 event \Codemacher\ (see usage example). If none of these options accept the referrer, you will receive error 1001.
Keep in mind: A referrer header can be spoofed, so this is not a strict access control check!
Leaflet Example
// Initialize the base layer
L.tileLayer('/tile-proxy/?provider=osm&z={z}&x={x}&y={y}', {
attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors',
}).addTo(map);
OpenLayer Example
var osmSource = new ol.source.XYZ({
attributions : '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors',
url: '/tile-proxy/?provider=osm&z={z}&x={x}&y={y}'
});
Nominatim-Proxy-Endpoint
With this extension you can define a page in the TYPO3 backend as an endpoint for geocoding request to nominatim.
If the slug for your page is e.g. geo-proxy, the data can be retrieved from:
/geo-proxy/?provider=osm&apitype=search&q=06120&format=json&addressdetails=1
Arguments
provider
Currently only osm (OpenStreetMap) is supported, so the value must be osm.
apitype
Type of the api endpoint. Permissible types are: 'search','reverse','lookup' see https://nominatim.org/release-docs/latest/api/Overview/
all other parameters
The parameters of the nominatim-api (e.g. q, street, city, postalcode, countrycodes, viewbox, lat, lon, zoom, osm_ids, format, limit, addressdetails, accept-language) are forwarded. Unknown parameters are dropped.
Rate limit
The usage policy of nominatim allows one request per second at most. Therefore requests which are not answered from the cache are sent one after the other with an interval of one second. If a request would have to wait for more than 3 seconds, it is rejected with the HTTP status 429 and error 1007.
If the request must be loaded and is not cached, this request will be mapped to:
https://nominatim.openstreetmap.org/search?q=06120&format=json&addressdetails=1
The http referrer must be your own domain, localhost or configured in page settings or extension configuration. If these options do not offer enough flexibility, you can implement your own logic for verifying the referrer via a listener to the PSR-14 event \Codemacher\ (see usage example). If none of these options accept the referrer, you will receive error 1001.
Keep in mind: A referrer header can be spoofed, so this is not a strict access control check!
Miscellaneous
\Codemacher\TileProxy\Event\IsReferrerAllowedEvent
This event is dispatched on a request to one of the proxy endpoints, when checking if the current HTTP request is permitted to access the endpoint by containing a valid referrer. A listener with custom logic can be implemented, if the existing whitelisting options do not offer enough flexibility.
By calling set on the event object, the request is permitted to access the endpoint. See also the example below.
The event object also provides some context about the current request:
get: The current PSR-7 request object.Request () get: An associative array containing the properties of the current page record.Page Record () get: An associative array containing the parsed flexform properties of the current page record.Flex Settings () get: The raw value of the current request's referrer headerReferrer () getThe host part of the referrer header, e.g.Referrer Domain () www.example. org
As the event implements Stoppable, propagation can be stopped via calling stop
Example: Allow the wildcard subdomain *.example.org :
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\EventListener;
use Codemacher\TileProxy\Event\IsReferrerAllowedEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
#[AsEventListener(
identifier: 'my-extension/tile-proxy-referrer'
)]
readonly class IsReferrerAllowedEventListener
{
public function __invoke(IsReferrerAllowedEvent $event): void
{
if (preg_match('/^.+\\.example\\.org$/', $event->getReferrerDomain()) === 1) {
$event->setAllowed(true);
$event->stopPropagation();
}
}
}