问题
Respected sir/ma'am I want to implement offline osm map in my project. but i don't found any proper documentation for how to download tiles for offline usage. i am currently using react-native-maps package for implementing custom Tile Overlay
import { LocalTile } from 'react-native-maps';
<MapView
region={this.state.region}
onRegionChange={this.onRegionChange}
>
<LocalTile
/**
* The path template of the locally stored tiles. The patterns {x} {y} {z} will be replaced at runtime
* For example, /storage/emulated/0/mytiles/{z}/{x}/{y}.png
*/
pathTemplate={this.state.pathTemplate}
/**
* The size of provided local tiles (usually 256 or 512).
*/
tileSize={256}
/>
</MapView>
回答1:
There is no straightforward approach for downloading offline raster tiles for OSM. Rendering these tiles is very resource intensive and depending on the zoom level the download and storage size of raster tiles will become huge. In other words: raster tiles should be avoided for offline use. You should consider using vector tiles instead.
Possible solutions:
- Render your own raster tiles, for example by using Maperitive
- Switch to a library supporting vector tiles and download them, for example from OpenMapTiles.com
来源:https://stackoverflow.com/questions/62149188/off-line-map-how-to-download-osm-tiles-to-use-off-line-map-in-react-native-map