Есть ли способ отобразить закодированную полилинию в приложении Google Maps с намерением Android?Android

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Anonymous
 Есть ли способ отобразить закодированную полилинию в приложении Google Maps с намерением Android?

Сообщение Anonymous »

Я работаю над приложением для Android, которое генерирует пути к местам тренировок в виде закодированной ломаной линии, и я хочу отображать закодированную ломаную линию в приложении Google Maps с намерением карты Google (https://developers.google.com/maps/documentation /urls/android-intents)
Я размещаю вопрос в Google Gemini и ChatGPT и получаю разные ответы, но никто не работает.
Примеры (среди прочих) ответов, полученных от Gemini и ChatGPT IA
Google Gemini
String encodedPolylineString = "your_encoded_polyline";
// Decode the polyline (replace with your implementation or use a library)
List decodedPoints = PolyUtil.decode(encodedPolylineString);

// Create the intent
Intent intent = new Intent(Intent.ACTION_VIEW);
String dataUri = "geo:0,0?q=polyline:" + encodedPolylineString;
intent.setData(Uri.parse(dataUri));
intent.setPackage("com.google.android.apps.maps");

// Start the activity (optional)
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
} else {
// Handle case where Google Maps is not installed
}

ChatGPT
// Example encoded polyline (make sure to replace this with your actual encoded polyline)
String encodedPolyline = "encoded_polyline_string_here";

// Create the URI for the encoded polyline
Uri gmmIntentUri = Uri.parse("https://www.google.com/maps/dir/?api=1& ... g&path=enc:" + encodedPolyline);

// Create an Intent from gmmIntentUri
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);

// Set the package to ensure that the intent is handled by Google Maps
mapIntent.setPackage("com.google.android.apps.maps");

// Check if the intent resolves to an activity (i.e., Google Maps is installed)
if (mapIntent.resolveActivity(getPackageManager()) != null) {
startActivity(mapIntent);
} else {
// Handle the case where Google Maps is not installed
// You could show a message to the user or redirect them to install Google Maps
}


Подробнее здесь: https://stackoverflow.com/questions/786 ... an-android
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Android»