osmdroid开发文档

osmdroid是一个几乎全面替代Android MapView(v1 API)的库,支持多种在线和离线切片源以及多种地图叠加操作。对于不使用Maven或Gradle的用户,可以从Maven Central下载并手动引入。本指南涵盖了如何在不使用构建系统的Eclipse中使用osmdroid,以及如何设置Manifest、布局和主要活动。此外,还提供了如何添加地图视图、图像按钮、自定义资源代理、地图覆盖层等高级教程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值