2

I will be offline (for mapping purposes) for a few weeks, but would like to continue working on my projects. Is there a way I can develop a leafletjs app while offline? I don’t want to create an offline map storage as I really don’t want to look at the maps. I just want leafletjs to not throw any errors while I code other (non-map) parts of the app.

update: to be clear, I want to be able to work with markers, coordinates, zoom, pan, etc. Just don't have to actually view the map tiles as there would be no connection to retrieve the maps.

1

Just do not add a TileLayer. That way, you won't make network requests to fetch the basemaps.

Another alternative is to download just one map tile (e.g. https://a.tile.openstreetmap.org/0/0/0.png), save somewhere in your computer, and have a TileLayer pointing at the file in your computer, like:

L.tileLayer('file://home/ivan/projects/whatever/tile-0.png',{
    minZoom: 0,
    maxZoom: 18,
    maxNativeZoom: 0
}).addTo(map);

It will probably look like crap, but at least you'll have something to show as a basemap, even if it's just one map tile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.