https://github.com/twoeightnine/staticmap
android-library to display static pieces of map
https://github.com/twoeightnine/staticmap
android kotlin library map
Last synced: 12 months ago
JSON representation
android-library to display static pieces of map
- Host: GitHub
- URL: https://github.com/twoeightnine/staticmap
- Owner: TwoEightNine
- License: mit
- Created: 2020-07-14T06:40:14.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-27T07:57:08.000Z (over 5 years ago)
- Last Synced: 2025-02-11T12:41:35.389Z (about 1 year ago)
- Topics: android, kotlin, library, map
- Language: Kotlin
- Homepage:
- Size: 3.64 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
## StaticMap
StaticMap is a library for showing a static piece of map without having to use powerful but hard-weight maps engines.
StaticMap API allows you to load a map right into `ImageView`.

### usage
add this dependency to your app-level `build.gradle`:
```groovy
implementation 'com.twoeightnine.staticmap:staticmap:0.1'
```
after sync is done create preferred `TileLoader` (loads image by url into bitmap) and
`TileProvider` (converts tile coordinates into tile url)
```kotlin
private inner class CustomTileLoader : TileLoader {
override fun loadTile(tileUrl: String, callback: TileLoader.Callback) {
try {
val bitmap = Glide.with(this@MainActivity)
.asBitmap()
.load(tileUrl)
.into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
.get()
callback.onLoaded(bitmap)
} catch (e: Exception) {
callback.onFailed(e)
}
}
}
private inner class CustomTileProvider : TileProvider {
override fun getTileUrl(tile: Tile): String =
"https://c.tile.openstreetmap.org/${tile.z}/${tile.x}/${tile.y}.png"
}
```
then load a map
```kotlin
val tileEssential = TileEssential(CustomTileProvider(), CustomTileLoader())
val pinIcon = ContextCompat.getDrawable(this, R.drawable.ic_pin)
var latLngZoom = LatLngZoom(0.0, 0.0, 16)
StaticMap.with(tileEssential)
.load(latLngZoom)
.pin(pinIcon)
.into(yourImageView)
```
##### issues and contribution are welcome!
#### twoeightnine, 2020