Offline hosting using openlayers

Hi everyone

I am really new on this!

I have developed a tracking web-based application using openlayers and OSM. Everything is working fine :slight_smile:
Now I need to make the application works offline i.e. host certain country map on my local server. I downloaded .OSM data for the required country.

My questions:

1- How I will render and host this data?
2- How I should included the hosted map in my code?

It may be very easy and basic to most of you guys, but I am struggling on this!

I do appreciate your help!

Thanks,
Buraq

Do you want to store bitmap tiles or vector tiles on your server?

What data storage, CPU and RAM size do you have on your local hardware in detail?

What are your results when you browse the OSM wiki for “Tiles” or “Vector Tiles” or “Rendering”?

Hi Stephan,

Thanks for your replay,

I want to use vector tiles.

My server is: 500 GB, RAM 4G, Intel(R) Core™ i5-3210M CPU @ 2.50GHz, 2501 Mhz, 2 Core(s)

I have not found a detailed results.

I appreciate your help.

Cheers,
Buraq

There’s quite a lot of stuff at https://switch2osm.org/serving-tiles/ . If the country that you’re talking about is the one that I think that it is (about the same size as Scotland in OSM terms) then your 4Gb server should deal with that OK. The tiles will be raster tiles (like the ones at OpenStreetMap), not vector, though. You can point OpenLayers at those tiles. An OSM tile has a URL like https://a.tile.openstreetmap.org/7/69/42.png . Your server will have a different URL; just use that when you set up the tile layer in OpenLayers.

If you absolutely want vector tiles have a look at https://openmaptiles.org/ - although it’s not something that I’ve got a lot of familiarity with.

Thanks a lot, I will have a look on what you mention.

This https://switch2osm.org/serving-tiles/ for Linux only right? I am using windows.

Here’s a diary entry that I wrote earlier: https://www.openstreetmap.org/user/SomeoneElse/diary/42617 . That was done with WSL1, but I’m sure it’d work with WSL2 as well. Also, I’m pretty sure that people have used https://switch2osm.org/serving-tiles/using-a-docker-container/ on Windows.

Having said that however, is there a logical reason why you’ want to use Windows for a tile server? You may of course have Windows-specific stuff in your main application, but you can view the tile server as a “black box” that just gives you tiles when you provide the appropriate URL.

Yes, we do have some other functions that need to be done under windows - user requirements!

Or a virtual machine. You could host a Linux VM inside your Windows box. Same idea as Docker.

An idea… OSM is available in country-sized chunks as vector maps, MapsForge format, and there’s a library for displaying the map directly, applying a theme to style the result as desired. This all fits in a phone. (In my phone’s case, all of Western Canada, a huge place, offline.)

Maybe just maybe… Has anybody written a module to convert the output from this MapsForge library, for a given square, into a vector tile as requested above? Seems simple enough: convert a square of vector data from one format to another. It might be a path to a solution…