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
This library provides a [OpenStreetMap](https://www.openstreetmap.org/) (OSM) map fetching and tile caching system for ESP32-based devices.
9
+
This PlatformIO library provides a [OpenStreetMap](https://www.openstreetmap.org/) (OSM) map fetching and tile caching system for ESP32-based devices.
10
10
Under the hood it uses [LovyanGFX](https://github.com/lovyan03/LovyanGFX) and [PNGdec](https://github.com/bitbank2/PNGdec) to do the heavy lifting.
11
11
12
12
[](https://www.openstreetmap.org/)
@@ -21,9 +21,8 @@ OSM tiles are quite large at 128kB or insane large at 512kB per tile, so psram i
21
21
22
22
### Multiple tile formats and providers are supported
23
23
24
-
Different tile formats and multiple tile providers?
25
-
Swap tile provider and tile format at runtime?
26
-
This library can do that and is very easy to configure and use.
24
+
You can switch provider and tile format at runtime, or set up a different default tile provider if you want.
25
+
This library can do it all and is very easy to configure and use.
- If no size is set a 320px by 240px map will be returned.
70
+
- The tile cache might need resizing if the size is increased.
59
71
60
72
### Get the number of tiles needed to cache a map
61
73
@@ -71,15 +83,15 @@ This returns the number of tiles required to cache the given map size.
71
83
boolresizeTilesCache(uint16_t numberOfTiles)
72
84
```
73
85
74
-
- If the cache is not resized before the first call to `fetchMap`, the cache will be auto initialized.
86
+
- If the cache is not resized before the first call to `fetchMap`, the cache will be auto initialized with the amount of tiles returned by `tilesNeeded(w, h)` where `w` and `h` are the current map width and height.
75
87
- The cache content is cleared before resizing.
76
88
- Each 256px tile allocates **128kB** psram.
77
89
- Each 512px tile allocates **512kB** psram.
78
90
79
91
**Don't over-allocate**
80
92
When resizing the cache, keep in mind that the map sprite also uses psram.
81
93
The PNG decoders -~50kB for each core- also live in psram.
82
-
Use the above `tilesNeeded` function to calculate a safe and sane cache size.
94
+
Use the above `tilesNeeded` function to calculate a safe and sane cache size if you change the map size.
- Valid range for the `zoom` level is from `getMinZoom()` to `getMaxZoom()`.
93
105
94
-
### Free the memory used by the tile cache
106
+
### Free the psram memory used by the tile cache
95
107
96
108
```c++
97
109
voidfreeTilesCache()
98
110
```
99
111
112
+
- Does **not** free the PNG decoder(s).
113
+
100
114
### Switch to a different tile provider
101
115
102
116
```c++
@@ -118,27 +132,24 @@ Example use:
118
132
const int numberOfProviders = OSM_TILEPROVIDERS;
119
133
```
120
134
121
-
In the default setup there is only one provider defined.
135
+
**Note:** In the default setup there is only one provider defined.
136
+
122
137
See `src/TileProvider.hpp` for example setups for [https://www.thunderforest.com/](https://www.thunderforest.com/) that only require an API key and commenting/uncommenting 2 lines.
123
138
124
139
Registration and a hobby tier are available for free.
125
140
126
-
### Get the provider name
141
+
### Adding tile providers
127
142
128
-
```c++
129
-
char *getProviderName()
130
-
```
143
+
Other providers should work if a new definition is created in `src/TileProvider.hpp`.
144
+
Check out the existing templates to see how this works.
131
145
132
-
### Get the minimum zoom level
146
+
If you encounter a problem or want to request support for a new provider, please check the [issue tracker](../../issues) for existing reports or [open an issue](../../issues/new).
0 commit comments