Skip to content

Commit

Permalink
Cache map styles to improve first launch experience
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed Nov 5, 2024
1 parent 61a8405 commit c058c19
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/src/androidMain/assets/dark.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":8,"sources":{"ne2_shaded":{"maxzoom":6,"tileSize":256,"tiles":["https://tiles.openfreemap.org/natural_earth/ne2sr/{z}/{x}/{y}.png"],"type":"raster"},"openmaptiles":{"type":"vector","url":"https://tiles.openfreemap.org/planet"}},"sprite":"https://tiles.openfreemap.org/sprites/ofm_f384/ofm","glyphs":"https://tiles.openfreemap.org/fonts/{fontstack}/{range}.pbf","layers":[{"id":"background","type":"background","paint":{"background-color":"rgb(12,12,12)"}},{"id":"water","type":"fill","source":"openmaptiles","source-layer":"water","filter":["all",["==",["geometry-type"],"Polygon"],["!=",["get","brunnel"],"tunnel"]],"paint":{"fill-antialias":false,"fill-color":"rgb(27 ,27 ,29)"}},{"id":"landcover_ice_shelf","type":"fill","source":"openmaptiles","source-layer":"landcover","maxzoom":8,"filter":["all",["==",["geometry-type"],"Polygon"],["==",["get","subclass"],"ice_shelf"]],"paint":{"fill-color":"rgb(12,12,12)","fill-opacity":0.7}},{"id":"landcover_glacier","type":"fill","source":"openmaptiles","source-layer":"landcover","maxzoom":8,"filter":["all",["==",["geometry-type"],"Polygon"],["==",["get","subclass"],"glacier"]],"paint":{"fill-color":"hsl(0,1%,2%)","fill-opacity":["interpolate",["linear"],["zoom"],0,1,8,0.5]}},{"id":"landuse_residential","type":"fill","source":"openmaptiles","source-layer":"landuse","maxzoom":9,"filter":["all",["==",["geometry-type"],"Polygon"],["==",["get","class"],"residential"]],"paint":{"fill-color":"hsl(0,2%,5%)","fill-opacity":0.4}},{"id":"landcover_wood","type":"fill","source":"openmaptiles","source-layer":"landcover","minzoom":10,"filter":["all",["==",["geometry-type"],"Polygon"],["==",["get","class"],"wood"]],"paint":{"fill-color":"rgb(32,32,32)","fill-opacity":["interpolate",["exponential",0.3],["zoom"],8,0,10,0.8,13,0.4],"fill-pattern":"wood-pattern","fill-translate":[0,0]}},{"id":"landuse_park","type":"fill","source":"openmaptiles","source-layer":"landuse","filter":["all",["==",["geometry-type"],"Polygon"],["==",["get","class"],"park"]],"paint":{"fill-color":"rgb(32,32,32)"}},{"id":"waterway","type":"line","source":"openmaptiles","source-layer":"waterway","filter":["==",["geometry-type"],"LineString"],"paint":{"line-color":"rgb(27 ,27 ,29)"}},{"id":"water_name","type":"symbol","source":"openmaptiles","source-layer":"water_name","filter":["==",["geometry-type"],"LineString"],"layout":{"symbol-placement":"line","symbol-spacing":500,"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-rotation-alignment":"map","text-size":12},"paint":{"text-color":"hsla(0,0%,0%,0.7)","text-halo-color":"hsl(0,0%,27%)"}},{"id":"building","type":"fill","source":"openmaptiles","source-layer":"building","minzoom":12,"filter":["==",["geometry-type"],"Polygon"],"paint":{"fill-antialias":true,"fill-color":"rgb(10,10,10)","fill-outline-color":"rgb(27 ,27 ,29)"}},{"id":"aeroway-taxiway","type":"line","source":"openmaptiles","source-layer":"aeroway","minzoom":12,"filter":["match",["get","class"],["taxiway"],true,false],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#181818","line-opacity":1,"line-width":["interpolate",["exponential",1.55],["zoom"],13,1.8,20,20]}},{"id":"aeroway-runway-casing","type":"line","source":"openmaptiles","source-layer":"aeroway","minzoom":11,"filter":["match",["get","class"],["runway"],true,false],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"rgba(60,60,60,0.8)","line-opacity":1,"line-width":["interpolate",["exponential",1.5],["zoom"],11,5,17,55]}},{"id":"aeroway-area","type":"fill","source":"openmaptiles","source-layer":"aeroway","minzoom":4,"filter":["all",["==",["geometry-type"],"Polygon"],["match",["get","class"],["runway","taxiway"],true,false]],"paint":{"fill-color":"#000","fill-opacity":1}},{"id":"aeroway-runway","type":"line","source":"openmaptiles","source-layer":"aeroway","minzoom":11,"filter":["all",["match",["get","class"],["runway"],true,false],["==",["geometry-type"],"LineString"]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#000","line-opacity":1,"line-width":["interpolate",["exponential",1.5],["zoom"],11,4,17,50]}},{"id":"road_area_pier","type":"fill","source":"openmaptiles","source-layer":"transportation","filter":["all",["==",["geometry-type"],"Polygon"],["==",["get","class"],"pier"]],"paint":{"fill-antialias":true,"fill-color":"rgb(12,12,12)"}},{"id":"road_pier","type":"line","source":"openmaptiles","source-layer":"transportation","filter":["all",["==",["geometry-type"],"LineString"],["match",["get","class"],["pier"],true,false]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"rgb(12,12,12)","line-width":["interpolate",["exponential",1.2],["zoom"],15,1,17,4]}},{"id":"highway_path","type":"line","source":"openmaptiles","source-layer":"transportation","filter":["all",["==",["geometry-type"],"LineString"],["==",["get","class"],"path"]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"rgb(27 ,27 ,29)","line-dasharray":[1.5,1.5],"line-opacity":0.9,"line-width":["interpolate",["exponential",1.2],["zoom"],13,1,20,10]}},{"id":"highway_minor","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":8,"filter":["all",["==",["geometry-type"],"LineString"],["match",["get","class"],["minor","service","track"],true,false]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#181818","line-opacity":0.9,"line-width":["interpolate",["exponential",1.55],["zoom"],13,1.8,20,20]}},{"id":"highway_major_casing","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":11,"filter":["all",["==",["geometry-type"],"LineString"],["match",["get","class"],["primary","secondary","tertiary","trunk"],true,false]],"layout":{"line-cap":"butt","line-join":"miter"},"paint":{"line-color":"rgba(60,60,60,0.8)","line-dasharray":[12,0],"line-width":["interpolate",["exponential",1.3],["zoom"],10,3,20,23]}},{"id":"highway_major_inner","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":11,"filter":["all",["==",["geometry-type"],"LineString"],["match",["get","class"],["primary","secondary","tertiary","trunk"],true,false]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"hsl(0,0%,7%)","line-width":["interpolate",["exponential",1.3],["zoom"],10,2,20,20]}},{"id":"highway_major_subtle","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":6,"maxzoom":11,"filter":["all",["==",["geometry-type"],"LineString"],["match",["get","class"],["primary","secondary","tertiary","trunk"],true,false]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#2a2a2a","line-width":["interpolate",["linear"],["zoom"],6,0,8,2]}},{"id":"highway_motorway_casing","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":6,"filter":["all",["==",["geometry-type"],"LineString"],["==",["get","class"],"motorway"]],"layout":{"line-cap":"butt","line-join":"miter"},"paint":{"line-color":"rgba(60,60,60,0.8)","line-dasharray":[2,0],"line-opacity":1,"line-width":["interpolate",["exponential",1.4],["zoom"],5.8,0,6,3,20,40]}},{"id":"highway_motorway_inner","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":6,"filter":["all",["==",["geometry-type"],"LineString"],["==",["get","class"],"motorway"]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":["interpolate",["linear"],["zoom"],5.8,"hsla(0,0%,85%,0.53)",6,"#000"],"line-width":["interpolate",["exponential",1.4],["zoom"],4,2,6,1.3,20,30]}},{"id":"road_oneway","type":"symbol","source":"openmaptiles","source-layer":"transportation","minzoom":15,"filter":["==",["get","oneway"],1],"layout":{"icon-image":"oneway","icon-padding":2,"icon-rotate":0,"icon-rotation-alignment":"map","icon-size":["interpolate",["linear"],["zoom"],15,0.5,19,1],"symbol-placement":"line","symbol-spacing":200},"paint":{"icon-opacity":0.5}},{"id":"road_oneway_opposite","type":"symbol","source":"openmaptiles","source-layer":"transportation","minzoom":15,"filter":["==",["get","oneway"],-1],"layout":{"icon-image":"oneway","icon-padding":2,"icon-rotate":180,"icon-rotation-alignment":"map","icon-size":["interpolate",["linear"],["zoom"],15,0.5,19,1],"symbol-placement":"line","symbol-spacing":200},"paint":{"icon-opacity":0.5}},{"id":"highway_motorway_subtle","type":"line","source":"openmaptiles","source-layer":"transportation","maxzoom":6,"filter":["all",["==",["geometry-type"],"LineString"],["==",["get","class"],"motorway"]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-color":"#181818","line-width":["interpolate",["exponential",1.4],["zoom"],4,2,6,1.3]}},{"id":"railway_transit","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":16,"filter":["all",["==",["geometry-type"],"LineString"],["all",["==",["get","class"],"transit"],["match",["get","brunnel"],["tunnel"],false,true]]],"layout":{"line-join":"round"},"paint":{"line-color":"rgb(35,35,35)","line-width":3}},{"id":"railway_transit_dashline","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":16,"filter":["all",["==",["geometry-type"],"LineString"],["all",["==",["get","class"],"transit"],["match",["get","brunnel"],["tunnel"],false,true]]],"layout":{"line-join":"round"},"paint":{"line-color":"rgb(12,12,12)","line-dasharray":[3,3],"line-width":2}},{"id":"railway_minor","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":16,"filter":["all",["==",["geometry-type"],"LineString"],["all",["==",["get","class"],"rail"],["has","service"]]],"layout":{"line-join":"round"},"paint":{"line-color":"rgb(35,35,35)","line-width":3}},{"id":"railway_minor_dashline","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":16,"filter":["all",["==",["geometry-type"],"LineString"],["all",["==",["get","class"],"rail"],["has","service"]]],"layout":{"line-join":"round"},"paint":{"line-color":"rgb(12,12,12)","line-dasharray":[3,3],"line-width":2}},{"id":"railway","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":13,"filter":["all",["==",["geometry-type"],"LineString"],["==",["get","class"],"rail"],["!",["has","service"]]],"layout":{"line-join":"round"},"paint":{"line-color":"rgb(35,35,35)","line-width":["interpolate",["exponential",1.3],["zoom"],16,3,20,7]}},{"id":"railway_dashline","type":"line","source":"openmaptiles","source-layer":"transportation","minzoom":13,"filter":["all",["==",["geometry-type"],"LineString"],["==",["get","class"],"rail"],["!",["has","service"]]],"layout":{"line-join":"round"},"paint":{"line-color":"rgb(12,12,12)","line-dasharray":[3,3],"line-width":["interpolate",["exponential",1.3],["zoom"],16,2,20,6]}},{"id":"highway_name_other","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","filter":["all",["!=",["get","class"],"motorway"],["==",["geometry-type"],"LineString"]],"layout":{"symbol-placement":"line","symbol-spacing":350,"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"]," ",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-max-angle":30,"text-pitch-alignment":"viewport","text-rotation-alignment":"map","text-size":10,"text-transform":"uppercase"},"paint":{"text-color":"rgba(80, 78, 78, 1)","text-halo-blur":0,"text-halo-color":"rgba(0, 0, 0, 1)","text-halo-width":1,"text-translate":[0,0]}},{"id":"highway_name_motorway","type":"symbol","source":"openmaptiles","source-layer":"transportation_name","filter":["all",["==",["geometry-type"],"LineString"],["==",["get","class"],"motorway"]],"layout":{"symbol-placement":"line","symbol-spacing":350,"text-field":["to-string",["get","ref"]],"text-font":["Noto Sans Regular"],"text-pitch-alignment":"viewport","text-rotation-alignment":"viewport","text-size":10},"paint":{"text-color":"hsl(0,0%,37%)","text-translate":[0,2]}},{"id":"boundary_state","type":"line","source":"openmaptiles","source-layer":"boundary","filter":["==",["get","admin_level"],4],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-blur":0.4,"line-color":"hsl(0,0%,21%)","line-dasharray":[2,2],"line-opacity":1,"line-width":["interpolate",["exponential",1.3],["zoom"],3,1,22,15]}},{"id":"boundary_country_z0-4","type":"line","source":"openmaptiles","source-layer":"boundary","maxzoom":5,"filter":["all",["==",["get","admin_level"],2],["!",["has","claimed_by"]]],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-blur":["interpolate",["linear"],["zoom"],0,0.4,22,4],"line-color":"hsl(0,0%,23%)","line-opacity":1,"line-width":["interpolate",["exponential",1.1],["zoom"],3,1,22,20]}},{"id":"boundary_country_z5-","type":"line","source":"openmaptiles","source-layer":"boundary","minzoom":5,"filter":["==",["get","admin_level"],2],"layout":{"line-cap":"round","line-join":"round"},"paint":{"line-blur":["interpolate",["linear"],["zoom"],0,0.4,22,4],"line-color":"hsl(0,0%,23%)","line-opacity":1,"line-width":["interpolate",["exponential",1.1],["zoom"],3,1,22,20]}},{"id":"place_other","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":14,"filter":["all",["==",["geometry-type"],"Point"],["match",["get","class"],["hamlet","isolated_dwelling","neighbourhood"],true,false]],"layout":{"text-anchor":"center","text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-justify":"center","text-offset":[0.5,0],"text-size":10,"text-transform":"uppercase"},"paint":{"text-color":"rgb(101,101,101)","text-halo-blur":1,"text-halo-color":"rgba(0,0,0,0.7)","text-halo-width":1}},{"id":"place_suburb","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":15,"filter":["all",["==",["geometry-type"],"Point"],["==",["get","class"],"suburb"]],"layout":{"text-anchor":"center","text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-justify":"center","text-offset":[0.5,0],"text-size":10,"text-transform":"uppercase"},"paint":{"text-color":"rgb(101,101,101)","text-halo-blur":1,"text-halo-color":"rgba(0,0,0,0.7)","text-halo-width":1}},{"id":"place_village","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":14,"filter":["all",["==",["geometry-type"],"Point"],["==",["get","class"],"village"]],"layout":{"icon-size":0.4,"text-anchor":"left","text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-justify":"left","text-offset":[0.5,0.2],"text-size":10,"text-transform":"uppercase"},"paint":{"icon-opacity":0.7,"text-color":"rgb(101,101,101)","text-halo-blur":1,"text-halo-color":"rgba(0,0,0,0.7)","text-halo-width":1}},{"id":"place_town","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":15,"filter":["all",["==",["geometry-type"],"Point"],["==",["get","class"],"town"]],"layout":{"icon-image":["step",["zoom"],"circle-11",9,""],"icon-size":0.4,"text-anchor":["step",["zoom"],"left",8,"center"],"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-justify":"left","text-offset":[0.5,0.2],"text-size":10,"text-transform":"uppercase"},"paint":{"icon-opacity":0.7,"text-color":"rgb(101,101,101)","text-halo-blur":1,"text-halo-color":"rgba(0,0,0,0.7)","text-halo-width":1}},{"id":"place_city","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":14,"filter":["all",["==",["geometry-type"],"Point"],["==",["get","class"],"city"],[">",["get","rank"],3]],"layout":{"icon-image":["step",["zoom"],"circle-11",9,""],"icon-size":0.4,"text-anchor":["step",["zoom"],"left",8,"center"],"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-justify":"left","text-offset":[0.5,0.2],"text-size":10,"text-transform":"uppercase"},"paint":{"icon-opacity":0.7,"text-color":"rgb(101,101,101)","text-halo-blur":1,"text-halo-color":"rgba(0,0,0,0.7)","text-halo-width":1}},{"id":"place_city_large","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":12,"filter":["all",["==",["geometry-type"],"Point"],["<=",["get","rank"],3],["==",["get","class"],"city"]],"layout":{"icon-image":["step",["zoom"],"circle-11",9,""],"icon-size":0.4,"text-anchor":["step",["zoom"],"left",8,"center"],"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-justify":"left","text-offset":[0.5,0.2],"text-size":14,"text-transform":"uppercase"},"paint":{"icon-opacity":0.7,"text-color":"rgb(101,101,101)","text-halo-blur":1,"text-halo-color":"rgba(0,0,0,0.7)","text-halo-width":1}},{"id":"place_state","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":12,"filter":["all",["==",["geometry-type"],"Point"],["==",["get","class"],"state"]],"layout":{"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-size":10,"text-transform":"uppercase"},"paint":{"text-color":"rgb(101,101,101)","text-halo-blur":1,"text-halo-color":"rgba(0,0,0,0.7)","text-halo-width":1}},{"id":"place_country_other","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":8,"filter":["all",["==",["geometry-type"],"Point"],["==",["get","class"],"country"],["!",["has","iso_a2"]]],"layout":{"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-size":["interpolate",["linear"],["zoom"],0,9,1,11],"text-transform":"uppercase"},"paint":{"text-color":"rgb(101,101,101)","text-halo-color":"rgba(0,0,0,0.7)","text-halo-width":1.4}},{"id":"place_country_minor","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":8,"filter":["all",["==",["geometry-type"],"Point"],["==",["get","class"],"country"],[">=",["get","rank"],2],["has","iso_a2"]],"layout":{"text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-size":["interpolate",["linear"],["zoom"],0,10,6,12],"text-transform":"uppercase"},"paint":{"text-color":"rgb(101,101,101)","text-halo-color":"rgba(0,0,0,0.7)","text-halo-width":1.4}},{"id":"place_country_major","type":"symbol","source":"openmaptiles","source-layer":"place","maxzoom":6,"filter":["all",["==",["geometry-type"],"Point"],["<=",["get","rank"],1],["==",["get","class"],"country"],["has","iso_a2"]],"layout":{"text-anchor":"center","text-field":["case",["has","name:nonlatin"],["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],["coalesce",["get","name_en"],["get","name"]]],"text-font":["Noto Sans Regular"],"text-size":["interpolate",["exponential",1.4],["zoom"],0,10,3,12,4,14],"text-transform":"uppercase"},"paint":{"text-color":"rgb(101,101,101)","text-halo-color":"rgba(0,0,0,0.7)","text-halo-width":1.4}}]}
1 change: 1 addition & 0 deletions app/src/androidMain/assets/light.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions app/src/androidMain/kotlin/map/MapViewExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ fun MapLibreMap.initStyle(context: Context) {
context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES

if (nightMode) {
setStyle("https://static.btcmap.org/map-styles/dark.json")
setStyle("asset://dark.json")
} else {
setStyle("https://static.btcmap.org/map-styles/light.json")
setStyle("asset://light.json")
}
}

0 comments on commit c058c19

Please sign in to comment.