2013-04-20 89 views
0

我想在我的PhoneGap/Android應用程序中添加月球地圖。適用於Android的Google地球插件

當我嘗試使用谷歌地球API的應用程序,我收到以下錯誤:

The Google Earth Plugin is currently only available on Windows and Mac OS X 10.6+. 

是否有其他的方式,甚至另一個API,創建地圖的月球的在移動設備上。

回答

1

目前還沒有任何發佈的Google地球安卓版的API 版本。當前版本處理搜索意圖。您可以通過 在Android中啓動Google地球,然後飛到 以下的位置:請記住,Google可以在任何 時間更改此設置,並且下面的代碼可能不起作用。

// the new intent we will launch 
Intent myIntent = new Intent(); 

// send the intent directly to the google earth activity that can 
handle search 
myIntent.setClassName("com.google.earth", 
"com.google.earth.EarthActivity"); 

// we are doing a search query 
myIntent.setAction(Intent.ACTION_SEARCH); 

// change this address to any address you want to fly to 
myIntent.putExtra(SearchManager.QUERY, "2900 Frenchmen Street, New 
Orleans, LA"); 

// always trap for ActivityNotFound in case Google earth is not on the 
device 
try { 
    // launch google earth and fly to location 
    this.startActivity(myScanIntent); 
} 
catch (ActivityNotFoundException e) { 
    showGoogleEarthDialog(); 
} 

... 

// if the user does not have google earth prompt to download it 
private void showGoogleEarthDialog() { 

     AlertDialog.Builder downloadDialog = new AlertDialog.Builder(this); 
     downloadDialog.setTitle("Install Google Earth?"); 
     downloadDialog.setMessage("This application requires Google Earth. 
Would you like to install it?"); 
     downloadDialog.setPositiveButton("Yes", new 
DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialogInterface, int i) { 
       Uri uri = Uri.parse("market://search? 
q=pname:com.google.earth"); 
       Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
       MainActivity.this.startActivity(intent); 
      } 
     }); 
     downloadDialog.setNegativeButton("No", new 
DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialogInterface, int i) {} 
     }); 
     downloadDialog.show(); 

}