Spe*_*cur 105 android google-maps android-intent android-maps
我有一个应用程序,我希望通过启动带有特定地理坐标的Google地图来显示不同的位置(当时一个,由用户输入选择).
我目前正在使用这个:(当然是真正的纬度和长值.)
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?z=17"));
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
这完全是我想要的,除了它没有显示指定点的任何指示符或标记.它只位于它的位置.
有没有办法在不使用MapView的情况下获取标记或其他内容?
Ken*_*ice 248
试试这个:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?q=<lat>,<long>(Label+Name)"));
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
如果您不想要标签,可以省略(标签+名称),它会根据最近的街道或其认为相关的其他东西随机选择一个.
xor*_*ate 45
接受的答案是正确的,除非您的标签中有&符号(&).
第5.1节规定:
如果最终URI要包含"查询"组件,请添加组件分隔符"?" 到结果的末尾,后跟编码的查询字符串.
对我们来说不幸的是,这样做也会逃避'=',这不是我们想要的.我们应该做的是:
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);
Run Code Online (Sandbox Code Playgroud)
Jor*_*sys 41
Double myLatitude = 44.433106;
Double myLongitude = 26.103687;
String labelLocation = "Jorgesys @ Bucharest";
Run Code Online (Sandbox Code Playgroud)
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<" + myLatitude + ">,<" + myLongitude + ">?q=<" + myLatitude + ">,<" + myLongitude + ">(" + labelLocation + ")"));
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
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);
Run Code Online (Sandbox Code Playgroud)
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);
Run Code Online (Sandbox Code Playgroud)
这个字符串适合我:
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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
72259 次 |
| 最近记录: |