无法使用CloudMade中的osmdroid显示切片

时间:2013-05-25 18:22:14

标签: android osmdroid cloudmade

我正在尝试使用CloudMade(或其他)制作osmdroid,但我无法显示任何只有空白方块的瓷砖。我在Log cat中唯一能看到的是

  

无法找到方法org.osmdroid.views.MapView.getScaleX,从方法org.osmdroid.views.overlay.SafeDrawOverlay.draw中引用

     

无法解析虚方法5572:Lorg / osmdroid / views / MapView; .getScaleX()

的AndroidManifest.xml          

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
<meta-data android:name="CLOUDMADE_KEY" android:value="heremycorrectkeyfromcloudmade" />
        <activity
            android:name="com.example.testosm.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

main_activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <org.osmdroid.views.MapView
        android:id="@+id/mapTest"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</RelativeLayout>

MainActivity.java

package com.example.testosm;

import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.tileprovider.util.CloudmadeUtil;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);        
    CloudmadeUtil.retrieveCloudmadeKey(getApplicationContext());
    MapView mapView = (MapView) findViewById(R.id.mapTest);     
    mapView.setTileSource(TileSourceFactory.CLOUDMADESMALLTILES);
    mapView.setBuiltInZoomControls(true);
    MapController mMapController = mapView.getController();
    mMapController.setZoom(13);
    GeoPoint gPt = new GeoPoint(51500000, -150000);
    //Centre map near to Hyde Park Corner, London
    mMapController.setCenter(gPt);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

1 个答案:

答案 0 :(得分:0)

我怀疑你的目标SDK太低了。 Osmdroid支持SDK 7,但如果您的设备更高,那么它将使用来自较新API的api调用。定位最新的SDK,但将您的最小SDK保持在7。