http://osmdroid.github.io/osmdroid/
osmdroid is a (almost) full/free replacement for Android's MapView (v1 API) class. It also includes a modular tile provider system with support for numerous online and offline tile sources and overlay support with built-in overlays for plotting icons, tracking location, and drawing shapes.
osmdroid是Android的MapView类的完全/免费的替代品。它还包括一个模块化的切片供应系统,支持大量的在线和离线切片来源,以及overlay支持,内置绘制图标,跟踪位置,并绘制形状的叠加操作。
Non-Maven, Non-Gradle users
If you are not yet using Maven or Gradle, you can include osmdroid by downloading directly from Maven Central.
如果你还没有使用过Maven或者Gradle,你可以离线下载然后包含进来。
You have a choice between using an AAR (for >=5.0) or JAR (for < 4.3) in your libs folder.
For versions < 4.3, you also need slf4j-api and slf4j-android.
Version >= v5.0
If you're still using Eclipse without a backing building system (maven/gradle), you'll probably want to google around on how to use AAR files with Eclipse. By now, most people have probably moved on to Android Studio with gradle, since it's really the only supported solution. Some users have reported success by unzipping the AAR and the classes jar files and then including them in the classpath.
如果你仍然在使用Eclipse,不能使用aar文件,因为aar文件只有Android Studio才能调用。那么怎么调用最新的osmdroid.jar包呢?有人发现可以这样做,解压aar,把其中的classes.jar包复制到你的libs目录下。
Good luck!
祝你好运!
"Hello osmdroid World"
osmdroid's MapView is basically a replacement for Google's MapView class. First of all, create your Android project, and follow HowToMaven if you're using Maven, or follow HowToGradle if you're using Gradle/Android Studio. This will help you get the binaries for osmdroid included in your project.
Manifest
In most cases, you will have to set the following authorizations in your AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
If you are only using parts of the library, you can adjust the permissions accordingly.
Online tile provider
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Offline tile provider and storing tiles
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Location provider
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Android 6.0+ devices require you have to check for "dangerous" permissions at runtime.
osmdroid requires the following dangerous permissions:WRITE_EXTERNAL_STORAGE and ACCESS_COARSE_LOCATION/ACCESS_FINE_LOCATION.
See OpenStreetMapViewer's implementation or