Android - 放大混合设置,谷歌地图只显示空白背景

时间:2012-01-24 06:24:36

标签: android google-maps zooming hybrid

在我的应用中,我正在显示带有指针的Google地图。我已经在market提交了该应用,我通过从市场下载来检查它。

默认情况下的地图显示在混合视图中。通常情况下地图看起来不错,但是当我尝试放大时,地图会显示空白背景,如下图所示 enter image description here

以下是我的地图代码:

class MapOverlay extends com.google.android.maps.Overlay {
    public boolean draw(Canvas canvas, MapView mapView,boolean shadow, long when) {
        super.draw(canvas, mapView, shadow);
        Point screenPts = new Point();

        mapView.getProjection().toPixels(p, screenPts);
        Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pin);            
        canvas.drawBitmap(bmp, screenPts.x, screenPts.y-100, null);         
        return true;
    }
} 

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map);

    Map = (ImageButton)findViewById(R.id.MapBtn);
    Hybrid = (ImageButton)findViewById(R.id.hybridBtn);

    mapView = (MapView) findViewById(R.id.mapView);
    mapView.setSatellite(true);

    mapController = mapView.getController(); 

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.getProvider(LocationManager.GPS_PROVIDER);

    Criteria criteria = new Criteria(); 
    criteria.setAccuracy(Criteria.ACCURACY_FINE); 

    String bestProvider = locationManager.getBestProvider(criteria, true);      
    p = new GeoPoint((int) (latPt * 1E6),(int) (lngPt * 1E6));

    mapController.animateTo(p);
    mapController.setZoom(16); 
    mapView.invalidate();
    mapView.setTraffic(true);
    mapController = mapView.getController();

    MapOverlay mapOverlay = new MapOverlay();
    List<Overlay> listOfOverlays = mapView.getOverlays();
    listOfOverlays.clear();
    listOfOverlays.add(mapOverlay);
}

清单:

<manifest xmlns:android="schemas.android.com/apk/res/android"; 
    package="com.app.ig.sap"
    android:versionCode="2"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="7" />

    <supports-screens
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:anyDensity="true"/>

    <uses-feature android:name="android.hardware.camera"/> 

    <application
        android:icon="@drawable/q_icon"
        android:theme="@android:style/Theme.Light"
        android:label="@string/app_name"
        android:debuggable="false"> 

        <uses-library android:name="com.google.android.maps" />

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

    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.FLASHLIGHT"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>

任何人都可以解释为什么地图在变焦时看起来像这样吗?

2 个答案:

答案 0 :(得分:1)

Siva根据您对我的评论的回复,这是 ,因为Google的服务器上没有图像,而是网络延迟。图像切片可能会超时加载 - 因此延迟时间你会看到灰色瓷砖(作为替代品,至少比空白屏幕更好)。您可以调整代码以测试用户的连接,并向用户显示一条消息,通知他们连接速度很慢,并且地图可能无法正确呈现。

答案 1 :(得分:0)

AFAIK表示您所请求的缩放级别在Google地图服务器上不可用,因为您要求提供在该缩放级别无法使用的卫星图像。