You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-19
Original file line number
Diff line number
Diff line change
@@ -12,41 +12,51 @@ MapGrid is a grid data structure that can be used as an abstraction over the map
12
12
13
13
You initialize a MapGrid by providing what kind of tiles it will hold and a factory to create these tiles. You also need to give the size of the tile. This applies only at the grid origin which is currently set to be at zero coordinates.
14
14
15
-
var grid = MapGrid<CustomData>(tileSize: 100000 /* meters */, factory: CustomTileFactory())
15
+
var grid = MapGrid<Tile>(tileSize: 100000 /* meters */)
16
16
17
-
Here is an example of a factory.
17
+
And here's an example on how to use it.
18
18
19
19
```
20
-
class CustomTileFactory: TileFactory<CustomTile> {
Finally you call `update(visibleRegion:)` to get new tiles for the given region. The new tiles you need to add to the map. This will also give you tiles that were removed from the grid and it is up to you to remove the contents of these tiles from the map.
32
+
And that's it! With MapGrid you only need to deal with the logic of handling new and removed tiles.
let cities = /* Get the cities for the region here */
44
+
return Tile(cities: cities)
45
+
}
43
46
```
44
47
45
-
And that's it! With MapGrid you only need to deal with the logic of handling new and removed tiles.
48
+
### Filling
49
+
50
+
With the grid you call `fill(toRegion:newTile:)` to get new tiles for the given region. As a result, you only get newly created tiles back and you need to update the UI with these tiles.
51
+
52
+
### Cropping
53
+
54
+
To remove tiles from the grid you use `crop(toRegion:)`. This will give you tiles that were removed from the grid and it is up to you to remove the contents of these tiles from the map.
0 commit comments