Skip to content

Commit

Permalink
some minor docs
Browse files Browse the repository at this point in the history
  • Loading branch information
podusowski committed Jul 3, 2023
1 parent b09249c commit e04fd3a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

Slippy maps widget for [egui](https://github.com/emilk/egui).

# Quick start

Walkers widget needs two objects which are stored somewhere in the application.

```rust
struct Osm {
tiles: Tiles,
map_memory: MapMemory,
}

impl Osm {
fn new(egui_ctx: Context) -> Self {
let mut map_memory = MapMemory::default();
map_memory.osm = true; // It's false by default.
Self {
tiles: Tiles::new(egui_ctx),
map_memory,
}
}
}
```

Once this is done, you can simply add `Map` widget to the `update` method:

```rust
ui.add(Map::new(
&mut self.tiles,
&mut self.map_memory,
my_position,
));
```

# Limitations

There are couple of limitations when using this library. Some of them will
Expand All @@ -15,5 +47,4 @@ particularly affected by some and I will try to prioritize.

Other suggestions are welcomed as well.


![Screenshot](screenshot.png)
1 change: 1 addition & 0 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ impl MapCenterMode {
}
}

/// State of the map widget which must persist between frames.
pub struct MapMemory {
pub center_mode: MapCenterMode,
pub osm: bool,
Expand Down
1 change: 1 addition & 0 deletions src/tiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl Tile {
}
}

/// Downloads and keeps cache of the tiles. It must persist between frames.
pub struct Tiles {
cache: Arc<Mutex<HashMap<TileId, Tile>>>,

Expand Down

0 comments on commit e04fd3a

Please sign in to comment.