适用于Android的Google地球插件

时间:2013-04-20 09:57:26

标签: android api google-maps plugins

我正在尝试在我的PhoneGap / Android应用程序上添加月球地图。

当我尝试在应用上使用Google地球API时,收到以下错误:

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

是否有另一种方法,甚至是另一种API,可以在移动设备上创建 Moon 的地图。

1 个答案:

答案 0 :(得分:2)

Google Earth Android目前没有任何已发布的API 版。当前版本确实处理搜索意图。您可以 在Android中启动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(); 

}