Jak pokazać znacznik w Mapach uruchomionych przez Geo URI Intent?

Mam aplikację, w której chcę pokazać różne lokalizacje (po jednej na raz, wybrane przez wejście użytkownika), uruchamiając Google Maps z ich konkretnymi współrzędnymi geograficznymi.

Obecnie używam tego (z prawdziwym lat. i długie. wartości oczywiście):

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?z=17"));
startActivity(intent);

Jest dokładnie tym, czego chcę, z wyjątkiem tego, że nie pokazuje żadnego wskaźnika ani markera dla określonego punktu. Skupia się tylko na jego miejscu.

Czy Jest jakiś sposób, aby dostać marker lub coś innego zawarte bez korzystania z MapView?

Author: Peter Mortensen, 2010-10-21

7 answers

Spróbuj tego:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?q=<lat>,<long>(Label+Name)"));
startActivity(intent);

Możesz pominąć (Etykieta+Nazwa), jeśli nie chcesz etykiety, i wybierze losowo jedną na podstawie najbliższej ulicy lub innej rzeczy, którą uważa za istotną.

 255
Author: Kenton Price,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-09-13 17:31:30

Zaakceptowana odpowiedź jest prawidłowa, z wyjątkiem sytuacji, gdy na etykiecie znajduje się Znak ampersand ( & ).

Patrząc na Uniform Resource Identifier for Geographic Locations ("geo" URI):

Sekcja 5.1 stwierdza:

Jeśli ostateczny URI ma zawierać komponent 'query', dodaj ogranicznik komponentów "?"do końca wyniku, po którym następuje zakodowany ciąg zapytania.

Niestety dla nas, zrobienie tego również wymknie się'=', które nie jest czego chcemy.

Powinniśmy to zrobić:

String label = "Cinnamon & Toast";
String uriBegin = "geo:12,34";
String query = "12,34(" + label + ")";
String encodedQuery = Uri.encode(query);
String uriString = uriBegin + "?q=" + encodedQuery;
Uri uri = Uri.parse(uriString);
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
startActivity(intent);
 45
Author: xorgate,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-06-04 01:19:22

Istnieje wiele innych opcji, aby uruchomić mapę Google za pomocą intencji...

   Double myLatitude = 44.433106;
   Double myLongitude = 26.103687;
   String labelLocation = "Jorgesys @ Bucharest";

1)

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<" + myLatitude  + ">,<" + myLongitude + ">?q=<" + myLatitude  + ">,<" + myLongitude + ">(" + labelLocation + ")"));
    startActivity(intent);

2)

String urlAddress = "http://maps.google.com/maps?q="+ myLatitude  +"," + myLongitude +"("+ labelLocation + ")&iwloc=A&hl=es";
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlAddress));
    startActivity(intent);

3)

   String urlAddress = "http://maps.googleapis.com/maps/api/streetview?size=500x500&location=" + myLatitude  + "," + myLongitude + "&fov=90&heading=235&pitch=10&sensor=false";
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlAddress));
        startActivity(intent);
 43
Author: Jorgesys,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-06-04 01:20:21

Ten ciąg działa dobrze dla mnie:

String geoUriString="geo:"+lat+","+lon+"?q=("+head+")@"+lat+","+lon;
Uri geoUri = Uri.parse(geoUriString);
Log.e(TAG, "String: "+geoUriString);
Intent mapCall  = new Intent(Intent.ACTION_VIEW, geoUri);
startActivity(mapCall);
 6
Author: The HCD,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-01-27 10:50:42

Spróbuj dodać (LocationMarkerName) do geo: uri. Na przykład " geo:,?z=17 (LocationMarkerName) "

W Google Maps na Androida szukanie 23.0980,30.6797 (NamedMarker), wydaje się wyśrodkować mapę i umieścić znacznik o nazwie NamedMarker w tej pozycji.

 2
Author: joshuau,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-06-04 01:18:14

[[1]}właśnie potwierdziłem następujący fragment z @ Kenton Price nadal działa na Androidzie 4.4 (KitKat):

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?q=<lat>,<long>(Label+Name)"));
startActivity(intent);
 1
Author: Fate Chang,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-06-04 01:19:57

Używałem tylko nakładek z MapView do rysowania znaczników na mapie. Jeśli Widok pokazuje mapę, możliwe jest po prostu narysowanie znacznika na środku ekranu, w taki sam sposób, jak każdy obraz na widoku.

Jednak znacznik nie byłby powiązany z rzeczywistymi współrzędnymi mapy, ale jeśli jest to tylko widok Statyczny, to może to zrobić.

 0
Author: John J Smith,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-06-04 01:17:29