2011-03-26 79 views
0

我想在我的Android應用程序中顯示特定的地方。我已經生成了Fingeprint密鑰並將其提交給Google並獲得了一個API密鑰。在Android應用程序中顯示地圖的問題

但還是在我的編碼有很多的錯誤,主要錯誤在以下導入文件

{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.MapView.LayoutParams;} 

以下是我的應用程序的代碼

{ 
public class ViewMap extends MapActivity 
{ 
    MapView mapView; 
    MapController mc; 
    GeoPoint p; 

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


     mapView = (MapView) findViewById(R.id.mapView); 
     LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom); 
     View zoomView = mapView.getZoomControls(); 

     zoomLayout.addView(zoomView, 
      new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); 
     mapView.displayZoomControls(true); 

     mc = mapView.getController(); 
     String coordinates[] = {"1.352566007", "103.78921587"}; 
     double lat = Double.parseDouble(coordinates[0]); 
     double lng = Double.parseDouble(coordinates[1]); 

     p = new GeoPoint(
      (int) (lat * 1E6), 
      (int) (lng * 1E6)); 

     mc.animateTo(p); 
     mc.setZoom(17); 
     mapView.invalidate();   
    } 

    protected boolean isRouteDisplayed() 
    { 
      return false; 
    } 
} 

} 

我有很多的錯誤裏面的編碼也是如GeoPoint,mc,MapView等

請幫我解決這個問題

+0

我必須添加任何新的包com.google.android與類文件,如MapView,GeoPoint等.... – 2011-03-26 05:24:26

回答

1

您是否選擇了谷歌的API爲您目標 - 請參閱此處顯示的圖像 enter image description here

+0

不,我沒有做到這一點,谷歌Api沒有列在我的屬性。如何得到它 – 2011-03-26 05:46:13

+0

雅我沒有這樣做,thanx剛纔我正在安裝包 – 2011-03-26 05:54:34

+0

現在我的編碼沒有運行它得到墜毀....你能幫我 – 2011-03-26 07:57:09

1

你的清單文件中是否有這樣的一行?

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

而且你可能要重寫isRouteDisplayed除非你主動提供路由信息

你至少需要這些做很多在圖形頁面

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; 
+0

你也添加了該行。 .. – 2011-03-26 05:20:46

+0

我是否必須添加任何新的包com.google.android與類文件,如MapView,GeoPoint等...... – 2011-03-26 05:22:45

+0

@Siva Kread以上 – apesa 2011-03-26 05:33:04

1

您的項目是否構建目標爲Google API或Android API?

就在你需要知道,你的項目右擊,進入屬性 - 案例> Android的

如果沒有谷歌的API,去窗口 - > Android SDK和AVD管理器 - >可用的軟件包 - >第三方插件,你應該能夠看到它

+0

雅我沒有做到這一點,thanx只是現在我正在安裝包 – 2011-03-26 05:54:13

+0

現在我的編碼沒有運行它得到崩潰....你能幫我 – 2011-03-26 07:57:33

相關問題