Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pengrad/MapScaleView
Scale bar for Android Maps (Google Maps, OSM, MapBox, Yandex)
https://github.com/pengrad/MapScaleView
android-maps
Last synced: 3 months ago
JSON representation
Scale bar for Android Maps (Google Maps, OSM, MapBox, Yandex)
- Host: GitHub
- URL: https://github.com/pengrad/MapScaleView
- Owner: pengrad
- License: apache-2.0
- Created: 2016-10-06T08:02:39.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-08-05T04:33:23.000Z (about 4 years ago)
- Last Synced: 2024-05-01T22:13:19.387Z (6 months ago)
- Topics: android-maps
- Language: Java
- Homepage:
- Size: 706 KB
- Stars: 115
- Watchers: 5
- Forks: 24
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-android - MapScaleView - Scale bar for Google Maps Android API (Libraries / Maps)
- awesome-android - MapScaleView - Scale bar for Google Maps Android API (Libraries / Maps)
README
# Map Scale View
[ ![Download](https://api.bintray.com/packages/pengrad/maven/mapscaleview/images/download.svg) ](https://bintray.com/pengrad/maven/mapscaleview/_latestVersion)
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-MapScaleView-green.svg?style=true)](https://android-arsenal.com/details/1/4541)Scale view for any Android Maps SDK (not only Google Maps)
![Image](images/image_rtl.png)
## Contributing
I encourage you to participate in this project. Feel free to open issues with bugs or ideas, fork and send pull requests.
Check [list of "help wanted" issues](https://github.com/pengrad/MapScaleView/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) to start with.## Usage
```groovy
dependencies {
implementation 'com.github.pengrad:mapscaleview:1.6.0'
}
```Include in layout file over map
```xml
```
With miles or custom style
```xml```
Update on map changed
```kotlin
val scaleView: MapScaleView = findViewById(R.id.scaleView)
val cameraPosition = map.cameraPosition
// need to pass zoom and latitude
scaleView.update(cameraPosition.zoom, cameraPosition.target.latitude)
```Full example with subscribing to map events and updating scale view
```kotlin
override fun onMapReady(googleMap: GoogleMap) {
map = googleMap
googleMap.setOnCameraMoveListener(this)
googleMap.setOnCameraIdleListener(this)
}override fun onCameraMove() {
val cameraPosition = map.cameraPosition
scaleView.update(cameraPosition.zoom, cameraPosition.target.latitude)
}override fun onCameraIdle() {
val cameraPosition = map.cameraPosition
scaleView.update(cameraPosition.zoom, cameraPosition.target.latitude)
}
```Refer to the sample project on how to use scale view with other Android Maps SDK (Mapbox).
## Customization
```java
mapScaleView.setColor(@ColorInt int color)
mapScaleView.setTextSize(float textSize)
mapScaleView.setStrokeWidth(float strokeWidth)
mapScaleView.setTextFont(Typeface font)// enable/disable white outline, enabled by default
mapScaleView.setOutlineEnabled(false)mapScaleView.metersAndMiles() // default
mapScaleView.metersOnly()
mapScaleView.milesOnly()// expand scale bar from right to left, disabled by default
mapScaleView.setExpandRtlEnabled(true)
```