2011-06-26 10 views
0

HTCの欲望があり、現在地を表示するアプリを作成しようとしています。Android、StreetViewがデバイスに正しく表示されないHtc Desire

私はアプリを書いて、私がどこにいるかを示すことができました。しかし私は自分の位置を衛星で見ることしかできません。私が試してみると、streetViewだけが表示されます。地図は空白になり、通りは表示されません。

ここに、streetViewを表示するために使用しようとしているコードを示します。

public class FindMeInMap extends MapActivity { 

@Override 
    protected boolean isRouteDisplayed() { 
    return false; 
    } 

    MapController mapController; 
    MyPositionOverlay positionOverlay; 

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

    MapView myMapView = (MapView)findViewById(R.id.theMapView); 
    myMapView.displayZoomControls(true); 
    myMapView.setBuiltInZoomControls(true); 
    mapController = myMapView.getController(); 

    myMapView.setSatellite(false); 
    myMapView.setStreetView(true); 
    myMapView.displayZoomControls(true); 
    myMapView.setTraffic(true); 





    // Add the MyPositionOverlay 
    positionOverlay = new MyPositionOverlay(); 
    List<Overlay> overlays = myMapView.getOverlays(); 
    overlays.add(positionOverlay); 

    LocationManager locationManager; 
    String context = Context.LOCATION_SERVICE; 
    locationManager = (LocationManager)getSystemService(context); 

    Criteria criteria = new Criteria(); 
    criteria.setAccuracy(Criteria.ACCURACY_FINE); 
    criteria.setAltitudeRequired(false); 
    criteria.setBearingRequired(false); 
    criteria.setCostAllowed(true); 
    criteria.setPowerRequirement(Criteria.POWER_LOW); 
    String provider = locationManager.getBestProvider(criteria, true); 

    Location location = locationManager.getLastKnownLocation(provider); 

    updateWithNewLocation(location); 

    locationManager.requestLocationUpdates(provider, 2000, 10, 
              locationListener); 
    } 

    private final LocationListener locationListener = new LocationListener() { 
    public void onLocationChanged(Location location) { 
     updateWithNewLocation(location); 
    } 

    public void onProviderDisabled(String provider){ 
     updateWithNewLocation(null); 
    } 

    public void onProviderEnabled(String provider){ } 
    public void onStatusChanged(String provider, int status, 
           Bundle extras){ } 
    }; 

    private void updateWithNewLocation(Location location) { 
    String latLongString; 
    TextView myLocationText; 
    myLocationText = (TextView)findViewById(R.id.myLocationText); 
    String addressString = "No address found"; 

    if (location != null) { 
     // Update my location marker 
     positionOverlay.setLocation(location); 

     // Update the map location. 
     Double geoLat = location.getLatitude()*1E6; 
     Double geoLng = location.getLongitude()*1E6; 
     GeoPoint point = new GeoPoint(geoLat.intValue(), 
            geoLng.intValue()); 

     mapController.animateTo(point); 
     mapController.setZoom(17); 


     double lat = location.getLatitude(); 
     double lng = location.getLongitude(); 
     latLongString = "Lat:" + lat + "\nLong:" + lng; 

     double latitude = location.getLatitude(); 
     double longitude = location.getLongitude(); 

     Geocoder gc = new Geocoder(this, Locale.getDefault()); 
     try { 
     List<Address> addresses = gc.getFromLocation(latitude, 
                longitude, 1); 
     StringBuilder sb = new StringBuilder(); 
     if (addresses.size() > 0) { 
      Address address = addresses.get(0); 

      for (int i = 0; i < address.getMaxAddressLineIndex(); i++) 
      sb.append(address.getAddressLine(i)).append("\n"); 

      sb.append(address.getLocality()).append("\n"); 
      sb.append(address.getPostalCode()).append("\n"); 
      sb.append(address.getCountryName()); 
     } 
     addressString = sb.toString(); 
     } catch (IOException e) {} 
    } else { 
     latLongString = "No location found"; 
    } 
    myLocationText.setText("Your Current Position is:\n" + 
          latLongString + "\n" + addressString); 
    } 
} 

誰もが私の問題を発見し、私は自分の欲望にこの作業を見ることができない理由を教えてもらえますか?エミュレータで同じコードを試してみましたが、それは電話ではなく、うまく動作しますか?

ありがとうございました!

+0

uは任意のソリューションを手に入れた...そして.....事前に感謝を教えてください... –

答えて

0

次のように変更します。?私は同じ問題を取得していますよう

myMapView.setSatellite(false); 
myMapView.setStreetView(true); 
myMapView.setBuiltInZoomControls(true); 
myMapView.postInvalidate(); 
関連する問題