EY refers to the global organization, and may refer to one or more, of the member firms of Ernst & Young Global Limited, each of which is a separate legal entity. Ernst & Young Global Limited, a UK company limited by guarantee, does not provide services to clients.
How EY can help
-
The EY Customer Experience solution can help your business integrate CX programs that help deliver sustainable long-term value. Discover more.
Read more
Step 3: Determine points of interest
Each tile takes up about 80 to 100 kb of space. Since the MyRangeBC app only deals with very specific parts of BC, I didn’t deem it necessary to have all of the tiles for all of BC. That would have resulted in a few GB of data. Instead, I went on and determined the longitude and latitude for points of interests only.
As part of this I also decided that the MyRangeBC application will only need access to certain tiles that are not fully zoomed in, since the use case is mostly for pastures and such. Essentially, we won’t need to zoom in as far as street level for our points of interest.
Step 4: Convert point of interest long/lat
Each tile has a unique X, Y and Z value. Z is the zoom level, while X and Y determine the specific tile. For the app to get the correct map tile, you need to use the following code to convert the longitude and latitude data into the X, Y, Z schema.
`TileMaster.swift`
```func convert(lat: Double, lon: Double, zoom: Int) -> MKTileOverlayPath {
// Scale factor used to create MKTileOverlayPath object.
let scaleFactor: CGFloat = 2.0
// Holders for X Y
var x: Int = 0
var y: Int = 0
let n = pow(2, Double(zoom))
x = Int(n * ((lon + 180) / 360))
y = Int(n * (1 - (log(tan(lat.degreesToRadians) + (1/cos(lat.degreesToRadians))) / Double.pi)) / 2)
return MKTileOverlayPath(x: x, y: y, z: zoom, contentScaleFactor: scaleFactor)
}```
If you know how many tiles you need ahead of time, you can easily figure out how much space your offline map will require. Simply take the total number of tiles you require and multiply it by 100KB.