Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using jpeg tiles in leaflet

Tags:

leaflet

As far as I can see, leaflet uses ".png" images for its tiles.

var mapOnlineUrl = 'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png';

Is there a way I could use jpeg images ? I am working on an offline mapping solution and the arial views quickly add up to huge sizes.

like image 914
w2olves Avatar asked Oct 25 '25 08:10

w2olves


1 Answers

Leaflet doesn't have any tiles. Your tileprovider does. In this case openstreetmap.fr. Since they've decided to use png files, you're stuck with that format. They are using that format because it's the smallest size (uses the lowest bandwidth) for that particular tileset. These free tilesets get used by a huge amount of users all over the world and it would be rather expensive for them to not have them properly optimized.

That's said most (i think) satellite imagery tilesets are in jpg format, here's an example of mapquest satellite tile:

http://oatile1.mqcdn.com/tiles/1.0.0/sat/15/5240/12661.jpg

Leaflet merely renders tiles from the tileserver you provide, in a grid using HTML img elements. It doesn't matter if use png, jpg, gif, bmp or something else in Leaflet, as long as your targeted browsers support that encoding format with the img tag.

like image 122
iH8 Avatar answered Oct 28 '25 04:10

iH8



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!