Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Tile / Map Server #298

Open
adamstern2000 opened this issue Apr 7, 2024 · 14 comments
Open

Custom Tile / Map Server #298

adamstern2000 opened this issue Apr 7, 2024 · 14 comments

Comments

@adamstern2000
Copy link

I carry a tile server for field work. I tried to directly modify the html/layers file, but it doesn't seem to make any changes to the web interface. Is there any way to add a custom tile server - it's url is very similar to an OSM server.

@wiedehopf
Copy link
Owner

clone the git, then:

./install.sh test

That will install with local modifications

@wiedehopf
Copy link
Owner

227 const customTiles = usp.get('customTiles');
228 if (customTiles)
229     loStore['customTiles'] = customTiles;
230 if (customTiles == 'remove')
231     loStore.removeItem('customTiles');


 27     if (loStore['customTiles'] != undefined) {
 28         custom_layers.push(new ol.layer.Tile({
 29             source: new ol.source.OSM({
 30                 "url" : loStore['customTiles'],
 31                 maxZoom: 15,
 32                 transition: tileTransition,
 33             }),
 34             name: 'custom_tiles',
 35             title: 'Custom tiles',
 36             type: 'base',
 37         }));
 38     }

This is in the code ... so you can do stuff with that within the limitations of that code.

Append ?customTiles=URL to the tar1090 URL and see if that works.

@adamstern2000
Copy link
Author

adamstern2000 commented Apr 8, 2024 via email

@Woutvstk
Copy link

Hello

I have the same problem here. For me, I am running a normal osm tileserver on a different machine on the same network.

The problem is that I don't know what exactly and where I need to change something.
I can find this piece of code:

 const customTiles = usp.get('customTiles');
 if (customTiles)
     loStore['customTiles'] = customTiles;
if (customTiles == 'remove')
    loStore.removeItem('customTiles');

in 3 differen files so i'm not sure where is should make changes.

Do I also have to change something in the second piece of code and where would that be located?

Do I change:
const customTiles = usp.get('customTiles');
to:
const customTiles = usp.get('10.0.0.2:83/default/{z}/{x}/{y}.png');
or something else?

Thanks in advance for your help

@wiedehopf
Copy link
Owner

Why didn't you try the URL i suggested?
It injects it locally into the page settings for the browser.

Append ?customTiles=URL to the tar1090 URL and see if that works.

@Woutvstk
Copy link

Woutvstk commented Apr 11, 2024

Oh now I see. I understood your message wrong.
Now the URL in my browser is:
http://10.0.0.4/tar1090/?customTiles=10.0.0.2:83/default/{z}/{x}/{y}.png
I do get the the option to select the custom tiles map but no tiles are loading. When I browse to the tileserver itself, everything works, and with: wget "10.0.0.2:83/default/5/10/2.png", I also get an image downloaded.

Edit: Addition of next part
The url: http://10.0.0.4/tar1090?customTiles=10.0.0.2:83/default/{z}/{x}/{y}.png gives a 404 error

@wiedehopf
Copy link
Owner

Well check the dev console what's wrong.

Possibly cross origin stuff.
Really this is for people to debug it themselves.
I might continue giving hints though :)

@Woutvstk
Copy link

Yes, I know I'm supposed to debug this myself but I am not very fluent in the web dev language.
Thank you for being willing to help me out anyways. I'll try not to waste your time : )
The tar1090 interface is in fact trying to get the png tiles but gets a 404 answer

The dev console says

GET http://10.0.0.4/tar1090/10.0.0.2:83/default/3/0/1.png 

but i feel like it should be trying

GET 10.0.0.2:83/default/3/0/1.png

Am I right about this or is this normal behavior?

@wiedehopf
Copy link
Owner

URLs start with http

@wiedehopf
Copy link
Owner

wiedehopf commented Apr 11, 2024

/tar1090/?customTiles=http://10.0.0.2:83/default/{z}/{x}/{y}.png

@Woutvstk
Copy link

I am now indeed getting Access-Control-Allow-Origin error like you said. I should be able to figure out now how to fix this...

@Woutvstk
Copy link

I managed to fix it, it was a cross origin access error. Thanks for the help!

@RundesBalli
Copy link

I managed to fix it, it was a cross origin access error. Thanks for the help!

Normally you would share your solution here now, so that other people with the same problem don't have to search for the solution in the future, but can adopt your solution.

@Woutvstk
Copy link

The thing is, i have been fiddling with a lot of config files to try to fix it so I'm not sure if this will be as helpful.
But you are correct. It could help someone in the future

Quick overview: I have a client(my laptop), front end tar1090 (server 1) and back en tileserver (server2)
What I think solved the problem was adding

    Header set Access-Control-Allow-Origin "*"

in

<Directory /srv/www/tileserver/public_site>
     Options Indexes FollowSymLinks
     AllowOverride None
     Require all granted
     Header set Access-Control-Allow-Origin "*"
</Directory>

in file /etc/apache2/apache2.conf on server2.

I also added:

Header set Access-Control-Allow-Origin "*"

in

<VirtualHost *:83>
    ServerAdmin     [email protected]
    ServerName      main.local
    ServerAlias     www.main.local
    DocumentRoot    /srv/www/tileserver/public_site/
    ErrorLog        /srv/www/tileserver/logs/error.log

in file /etc/apache2/sites-enabled/tileserver.conf on server2

Hope that helps!

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

No branches or pull requests

4 participants