2011-05-07 5 views
0

내 앱에 Google지도를 표시하고 싶습니다. map api 키가 있는데 내 xml 파일에서 사용하지만 Google지도가 표시되지 않고 앱 실행시 직사각형 블록 만 표시됩니다. 내 앱에서 Google지도를 표시하려면 어떻게해야하나요?내 앱에서 Google지도를 표시하는 방법

활동 클래스는 다음과 같습니다

public class ShowMap extends MapActivity { 

    private MapController mapController; 
    private MapView mapView; 
    private LocationManager locationManager; 

    public void onCreate(Bundle bundle) { 
     super.onCreate(bundle); 
     setContentView(R.layout.main); // bind the layout to the activity 

     // create a map view 
     RelativeLayout linearLayout = (RelativeLayout) findViewById(R.id.mainlayout); 
     mapView = (MapView) findViewById(R.id.mapview); 
     mapView.setBuiltInZoomControls(true); 
     mapView.setStreetView(true); 
     mapController = mapView.getController(); 
     mapController.setZoom(14); // Zoon 1 is world view 
     locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
     locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 
       0, new GeoUpdateHandler()); 
    } 

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

    public class GeoUpdateHandler implements LocationListener { 

     @Override 
     public void onLocationChanged(Location location) { 
      int lat = (int) (location.getLatitude() * 1E6); 
      int lng = (int) (location.getLongitude() * 1E6); 
      GeoPoint point = new GeoPoint(lat, lng); 
      mapController.animateTo(point); // mapController.setCenter(point); 
     } 

     @Override 
     public void onProviderDisabled(String provider) { 
     } 

     @Override 
     public void onProviderEnabled(String provider) { 
     } 

     @Override 
     public void onStatusChanged(String provider, int status, Bundle extras) { 
     } 
    } 

layout/main.xml 내가 디버그 키를 사용하고 생각

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mainlayout" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <com.google.android.maps.MapView 
     android:id="@+id/mapview" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:clickable="true" 
     android:enabled="true" 
     android:apiKey="0mT--u1GbHdhnBJgPZU8zhoF2e4qdpCag32e7lQ" /> 

</RelativeLayout> 
+0

코드는 괜찮아 보이는 ... 당신을 위해 작동합니다 this.Hope이보십시오. API 키가 맞습니까? – slhck

답변

0

입니다. 대신 사용하여 릴리스 키를 사용 : 자세한 내용은

keytool -list -keystore filename.keystore 

this

체크 아웃 :

+0

"keytool -list -keystore filename.keystore"를 사용하는 방법은 실제로 java와 android에서 새로운 기능이므로 pls는 간결한 pls pls를 설명합니다. – SRam

+0

앱의 키 저장소를 만들었습니까? .bat 파일을 생성하고 (예 : shell.bat라고하는 새 파일을 작성하고 편집 한 다음 cmd를 작성한 다음 저장하고 두 번 클릭하십시오.) 해당 위치에서 명령 프롬프트가 열립니다. 파일이 있으면 해당 명령 프롬프트에 위의 행을 입력하십시오. 그런 다음 디버그 키를 생성하는 것과 동일한 프로세스를 수행하십시오. –

관련 문제