2011-02-04 87 views
3

我对此很陌生。我正在创建一个定位我的联系人的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> 
+1

那么,究竟是你的问题/问题? – Adinia 2011-02-04 14:47:00

+0

@adinia如何将Google地图替换为openstreet地图。 – gutentag 2011-02-04 14:52:03

回答

3

我没有听说过开放街道地图到现在为止,但一个简单的搜索让我到他们的页面,在这里你可以找到API它。

另外,here你可以看看一些实现开放式街道地图的Android应用程序的代码。

5

mapsforge library似乎也非常有前途。似乎它们与GoogleMaps API兼容,并且您只需交换导入。

0

添加下面一行:

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"/>