2011-05-07 54 views
0

我正在處理一個android項目,我需要設置我的地圖以放大並顯示我的地圖的更詳細的視圖,就像我希望我的座標進行三角測量的街道一樣。問題是在Mapview類中,setStreetView已被棄用,wat是替代方案嗎? 這是setStreetView在我使用它時的樣子。如何在我的地圖視圖中設置streetView

package com.HelloMapView; 

import java.util.List; 

import com.google.android.maps.GeoPoint; 
import com.google.android.maps.MapActivity; 
import com.google.android.maps.MapController; 
import com.google.android.maps.MapView; 
import com.google.android.maps.Overlay; 
import com.google.android.maps.OverlayItem; 

import android.app.Activity; 
import android.graphics.drawable.Drawable; 
import android.os.Bundle; 
import android.widget.LinearLayout; 

public class HelloMapView extends MapActivity { 
    MapView mapview; 
    LinearLayout linearlayout; 
    List<Overlay> mapOverlay; 
    Drawable drawable; 
    HelloItemizedOverlay itemizedOverlay; 
    @SuppressWarnings("deprecation") 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     mapview=(MapView)findViewById(R.id.mapview); 
     mapview.setBuiltInZoomControls(true); 
     mapview.setStreetView(true); 
     mapOverlay=mapview.getOverlays(); 
     drawable=this.getResources().getDrawable(R.drawable.androidmarker); 
     itemizedOverlay=new HelloItemizedOverlay(drawable); 
     GeoPoint geoPoint=new GeoPoint(19240000,-99120000); 
     OverlayItem overlayitem=new OverlayItem(geoPoint,"",""); 
     itemizedOverlay.addoverlay(overlayitem); 
     mapOverlay.add(itemizedOverlay); 
    } 

    @Override 
    protected boolean isRouteDisplayed() { 
     // TODO Auto-generated method stub 
     return false; 
    } 
} 

這不起作用那隻能說明方盒子,沒有地圖在所有

回答

0

使用setStreetView(布爾)MapView類的

+1

setStreetView(布爾)是DEPRECATED。在Google API 11 – John 2011-05-07 09:01:37

+1

上,您可以使用mapView.setSatellite(true);也。 – 2011-05-07 09:21:16

0
myMapView.setStreetView(true); 
+0

此方法被標記爲** DEPRECATED作爲關閉SDK級別11 ** – martyglaubitz 2014-02-28 16:24:44

0

公共類ABC延伸MapActivity {

private static MapController myMapController = null; 
private static GeoPoint geoPoint = new GeoPoint 

( (INT)(25.24243399999999 * 1E6),(INT)(55.30611937301637 * 1E6));

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 


    setContentView(R.layout.contact_us_layout); 

    MapView mapView = (MapView) findViewById(R.id.mapview); 
    mapView.displayZoomControls(false); 
    mapView.setBuiltInZoomControls(true); 
    mapView.setFocusable(true); 
    myMapController = mapView.getController(); 
    myMapController.animateTo(geoPoint); 
    myMapController.setZoom(15); 
    // mapView.invalidate(); 
    // mapView.setFocusable(true); 
    myMapController.setCenter(geoPoint); 
    List<Overlay> mapOverlays = mapView.getOverlays(); 
    Drawable drawable = this.getResources().getDrawable(
      R.drawable.mapmarker); 
    HelloItemizedOverlay itemizedOverlay = new HelloItemizedOverlay(
      drawable, this); 

    OverlayItem overlayItem = new OverlayItem(geoPoint, 
      "abc"); 

    itemizedOverlay.addOverlay(overlayItem); 


    mapOverlays.add(itemizedOverlay); 

    //mapView.setSatellite(true); 
    **mapView.setStreetView(true);** 

公共類HelloItemizedOverlay延伸ItemizedOverlay { 私人ArrayList的mOverlays =新的ArrayList(); private Context mContext;

public HelloItemizedOverlay(Drawable defaultMarker, Context context) { 
     super(boundCenterBottom(defaultMarker)); 
     mContext = context; 
    } 

    public void addOverlay(OverlayItem overlay) { 
     mOverlays.add(overlay); 
     populate(); 
    } 

    @Override 
    protected OverlayItem createItem(int i) { 
     return mOverlays.get(i); 
    } 

    @Override 
    public int size() { 
     return mOverlays.size(); 
    } 

    @Override 
    protected boolean onTap(int index) { 
     OverlayItem item = mOverlays.get(index); 
     AlertDialog.Builder dialog = new AlertDialog.Builder(mContext); 
     dialog.setTitle(item.getTitle()); 
     dialog.setMessage(item.getSnippet()); 
     dialog.show(); 
     return true; 
    } 
} 

}

你好,,, 我已經發布了什麼ü希望... 如果地圖不顯示任何工作代碼。您的api密鑰沒有正確簽名..請再次簽名並在mapView中提供。 如果你想使用地圖街景的: mapView.setStreetView(真) 如果你想使用地圖的satelliteView: mapView.setSatellite(真)

+0

我的模擬器無法連接到互聯網,這可能是問題,因爲您的代碼不工作,並且setStreetView據說在eclipse Google API 11中被拒絕。 – John 2011-05-07 12:48:40

+0

所提供的代碼是專爲谷歌APi 2.2 .... – 2011-05-09 05:32:20

相關問題