Skip to content

Instantly share code, notes, and snippets.

View mellet's full-sized avatar
🏠
Working from home

Mellet Solbakk mellet

🏠
Working from home
View GitHub Profile
import React from 'react'
import { MapView, FileSystem, Constants } from 'expo'
import { Button } from 'react-native-elements'
export default class App extends React.Component {
state = {
urlTemplate: 'http://c.tile.openstreetmap.org/{z}/{x}/{y}.png',
offlineUrlTemplate: `${FileSystem.documentDirectory}tiles/{z}/{x}/{y}.png`,
isOffline: false,
mapRegion: undefined
@mellet
mellet / FetchTiles.js
Last active December 30, 2019 23:01
Download tiles
function async fetchTiles(tileGrid, rootFolder, tileServerUrl) {
/*
* For Expo to be able to download the tiles,
* the directories have to be created first.
*/
const create_directories = tileGrid.map((tile) => {
const folder = `${rootFolder}/${tile.z}/${tile.x}`
return FileSystem.makeDirectoryAsync(folder, {
intermediates: true,
})
@mellet
mellet / TileGrid.js
Last active October 29, 2021 06:33
Expo offline map support
export function tileGridForRegion(region, minZoom, maxZoom) {
let tiles = []
for (let zoom = minZoom; zoom <= maxZoom; zoom++) {
const subTiles = tilesForZoom(region, zoom)
tiles = [...tiles, ...subTiles]
}
return tiles
}
@mellet
mellet / BetterTouchToolsReadMe.md
Last active July 18, 2018 20:55
BetterTouchTools show crypto value

Setup BetterTouchTools

  1. Install BetterTouchTools and "JSON Helper for Apple Script" from the App Store.
  2. Set up a widget inside BetterTouchTools
  • Global -> Click +Widget
  • In Select toucbar wigdet pick the option Run Apple Script and Show Return Value
  • Click Advanced Configuration
  • Paste the script and click Run Script to validate that it works.
-- Settings
set coinName to "bitcoin" -- Name of coin
@mellet
mellet / .gitignore
Created September 10, 2013 21:29 — forked from adamgit/.gitignore
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# Version 2.0
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2013 updates:
# - fixed the broken "save personal Schemes"
#
# NB: if you are storing "built" products, this WILL NOT WORK,