nextcloud / nextcloud/maps

using a non-default tile.

Open
#1,319 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage enhancement
Dominant language
JavaScript
Stars
598
Forks
113
PR merge metrics
No merged PRs in 30d

Description

Issue
In some countries or regions, *.openstreetmap.org is Blocked by ISP, which can prevent the map from loading.

Solution I am using in maps version 1.2.0
Just using anoter tile server, such as tile.openstreetmap.de, by changing the js file:

# Edit <nextcloud_path>/apps/maps/js/maps-main.js
# Change
......{id:"osm",name:"Street map",type:Mt,url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",......
# to
......{id:"osm",name:"Street map",type:Mt,url:"https://tile.openstreetmap.de/{z}/{x}/{y}.png",......

It works fine in 1.2.0 and nextcloud 27.

Issue in maps version 1.4.0
However after update to 1.4.0, this kind of edit js file no longer work, Refused by CSP in browser :

Refused to load the image 'https://tile.openstreetmap.de/2/1/1.png' because it violates the following Content Security Policy directive:

I tried to add tile.openstreetmap.de into csp by

# Edit <nextcloud_path>/apps/maps/lib/Controller/PublicPageController.php
# add a new line in line 217:
            $csp->addAllowedImageDomain('https://*.tile.openstreetmap.org');
            $csp->addAllowedImageDomain('https://tile.openstreetmap.de');                             # new added line
            $csp->addAllowedImageDomain('https://server.arcgisonline.com');

However it still not work.

Describe alternatives you've considered
Official support for custom tile servers

Additional context
Is it possible to fix the csp issue before the custom tile is officially supported?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with apps/maps/js/maps-main.js and lib/Controller/PublicPageController.php, then inspect how tile URLs and CSP image domains are defined in version 1.4.0. Reproduce the blocked request in a browser and trace the generated policy. Done means a supported custom tile-server configuration loads map tiles without requiring edits to generated JavaScript or controller files.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.