wiedehopf / tar1090

Provides an improved webinterface for use with ADS-B decoders readsb / dump1090-fa
Other
1.21k stars 222 forks source link

Custom Tile / Map Server #298

Open adamstern2000 opened 2 months ago

adamstern2000 commented 2 months ago

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 commented 2 months ago

clone the git, then:

./install.sh test

That will install with local modifications

wiedehopf commented 2 months ago
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 commented 2 months ago

Thanks buddy!

Thank you,

Adam Stern President d:760.585.4084 t: 760.585.4090 e: @.**@.> a: Infinitely Virtual 1920 Hillhurst Avenue Suite 290 Los Angeles, CA 90027 w: www.infinitelyvirtual.comhttp://www.infinitelyvirtual.com/

On Apr 8, 2024, at 01:14, wiedehopf @.***> wrote:

 You don't often get email from @.*** Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

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.

— Reply to this email directly, view it on GitHubhttps://github.com/wiedehopf/tar1090/issues/298#issuecomment-2042129942, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AK6IIJLPEIZWW2YE3X4ZI4LY4JGUPAVCNFSM6AAAAABF3WE3SSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBSGEZDSOJUGI. You are receiving this because you authored the thread.Message ID: @.***>

Woutvstk commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

URLs start with http

wiedehopf commented 2 months ago

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

Woutvstk commented 2 months ago

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 commented 2 months ago

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

RundesBalli commented 2 months ago

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 commented 2 months ago

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     admin@local.com
    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!