2013-04-20 3 views
0

Я пытаюсь добавить карту Луны в приложение PhoneGap/Android.Плагин Google Earth для Android

Когда я пытаюсь использовать API Google Earth на приложение, я получаю следующее сообщение об ошибке:

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

Есть ли альтернативный способ, может быть, даже другой API, чтобы создать карту Луны на мобильном устройстве.

ответ

1

В настоящее время нет опубликованных API API для Google Планета Земля Android . Текущая версия поддерживает поиск. Вы можете запустить Google Earth на 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(); 

} 
Смежные вопросы