替换谷歌地图打开街道地图
问题描述:
我对此很陌生。我正在创建一个定位我的联系人的Android应用程序。我尝试了一些教程并运行。但如何取代谷歌地图打开街道地图。我有这个代码。替换谷歌地图打开街道地图
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.PositionLocator.android">
<application android:icon="@drawable/icon">
<activity android:name=".PositionLocator" android:label="@string/app_name">
</activity>
<activity android:name=".PositionLocatorMap" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
</manifest>
答
添加下面一行:
compile 'org.osmdroid:osmdroid-android:5.6.2'
到您的build.gradle(模块:应用程序)文件的依赖。
dependencies {
//Other required dependencies
compile 'org.osmdroid:osmdroid-android:5.6.2'
}
这将包括项目所需的所有OSM库。
在XML文件中(地图画面)与已经书面谷歌地图的代码替换下面的代码:
<!--<fragment-->
<!--android:layout_width="fill_parent"-->
<!--android:layout_height="fill_parent"-->
<!--android:id="@+id/mapview"-->
<!--tools:context="cabse.ui.MapActivity"-->
<!--android:name="com.google.android.gms.maps.SupportMapFragment"-->
<!--android:layout_below="@+id/header" />-->
<org.osmdroid.views.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:layout_below="@+id/header"
android:layout_above="@+id/layout_for_buttons"/>
那么,究竟是你的问题/问题? – Adinia 2011-02-04 14:47:00
@adinia如何将Google地图替换为openstreet地图。 – gutentag 2011-02-04 14:52:03