0

Currently I am using leafletjs for showing maps. Is there a way I can detect browser offline or online status.

  • https://www.html5rocks.com/en/mobile/workingoffthegrid/ – Anatolii Suhanov May 01 '18 at 04:13
  • Thanks for the suggestion. But actually the leafletjs library internally calls osm.org in order to get the '.png' files. I see it call multiple urls with different sub domaine based based on the zoom level. for example a.osm.org/1/2/3 b.osm.org/2/4/5 and so on. Not sure if I can check the connectivity with a specific url ? As the url are continuously changing. – Pradyumna Ravuri May 03 '18 at 00:03
  • 1
    You can omit the subdomain, e.g. by using https://tile.openstreetmap.org/0/0/0.png instead of https://c.tile.openstreetmap.org/0/0/0.png. The subdomains are just used to trick the browser into creating more simultaneous connections than with a single domain, as far as I know. – scai May 03 '18 at 10:33
  • 1
    Re " leafletjs library internally calls osm.org in order to get the '.png' files" - not really; it fetches .png tiles from wherever you say they should come from. That might be OSM's own tiles (subject to the usage limits!) or can be anywhere you specify, such as local storage. – SomeoneElse May 08 '18 at 10:56
  • @scai Yep, I see I can simply call tile.openstreetmap instead of calling with subdomine. – Pradyumna Ravuri May 08 '18 at 23:22
  • @SomeoneElse. I see it is caching those images when its online or get it from osm server I guess. But yeah currently I am replacing the tile which is not loaded with some error image. this helps me to detect if the browser is offline or for some reason not able load the images. Not sure its a correct way to do this. – Pradyumna Ravuri May 08 '18 at 23:26

0 Answers0