本文介绍了Android - 如何在Android应用程序中启动Google地图意图,同时设置缩放级别和标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与此问题非常相似(),但接受的答案不适合我。它会在正确的地方以正确的缩放级别打开地图,然后继续放大到街道视图(zoom = 16或17?)。



我搜索过,我已阅读文件,但无法找到位置标记和放大器的组合。放大,做我所需要的。



我已经尝试了一些使用Google地图版本的设备
8.2.0,
9.20.1,
9.36.2&
9.42.3



下面是日志打印结果(Uri用于此目的)
geo:39.29038619995117,-76.61219024658203?q = 39.29038619995117%2C-76.61219024658203(巴尔的摩)& z = 11

另一篇文章的答案现在是4岁。地图改变了,这样现在不起作用了吗?另一个答案是否只工作,因为他们将缩放设置为17,并没有注意到它不会解决另一个缩放级别?我错过了别的吗?

为了清楚说明我的问题:
如何使用地理意图打开地图应用程序以显示地点标记并同时选择缩放级别?



我的代码基于其他帖子接受的答案。

  double latitude = item.getLatitude(); 
double longitude = item.getLongitude();
String label = item.getName();
String uriBegin =geo:+ latitude +,+ longitude;
String query = latitude +,+ longitude +(+ label +);
String encodedQuery = Uri.encode(query);
String uriString = uriBegin +?q =+ encodedQuery +& z = 11;
mListener.onListFragmentInteraction(uriString);

然后

  public void onListFragmentInteraction(String url){
Uri geoLocation = Uri.parse(url);
Log.d(TAG,geo uri =+ geoLocation);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(geoLocation);
startActivity(intent);


解决方案

必须在此处添加隐藏地图功能内容链接()


My question is very similar to this question (Android - How to launch Google map intent in android app with certain location, zoom level and marker) but the accepted answer is not working for me. It opens the map with the marker at the correct place and at the correct zoom level but then proceeds to zoom in to a street level view (zoom=16 or 17?).

I've search SO, I've read through this documentation but can't find a combination of place marker & zoom that do what I need.

I've tried with a few devices using Google Maps versions8.2.0,9.20.1,9.36.2 &9.42.3

Here is the result of the log print (the Uri used for the intent)geo:39.29038619995117,-76.61219024658203?q=39.29038619995117%2C-76.61219024658203(Baltimore)&z=11

The answer from the other post is 4 years old now. Has Maps changed such that this doesn't work now? Did the other answer only work because they were setting the zoom to 17 and didn't notice it wouldn't settle on another zoom level? Am I missing something else?

To clearly state my question:How can I use a geo intent to open a maps app to show a place marker and simultaneously choose a zoom level?

My code, based on the accepted answer from the other post.

double latitude = item.getLatitude();
double longitude = item.getLongitude();
String label = item.getName();
String uriBegin = "geo:" + latitude + "," + longitude;
String query = latitude + "," + longitude + "(" + label + ")";
String encodedQuery = Uri.encode(query);
String uriString = uriBegin + "?q=" + encodedQuery + "&z=11";
mListener.onListFragmentInteraction(uriString);

Then

public void onListFragmentInteraction(String url) {
    Uri geoLocation = Uri.parse(url);
    Log.d(TAG, "geo uri = " + geoLocation);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(geoLocation);
    startActivity(intent);
}
解决方案

@Gary99 for removing restaurant u have to add hiding map feature content here is the link(https://developers.google.com/maps/documentation/android-api/hiding-features)

这篇关于Android - 如何在Android应用程序中启动Google地图意图,同时设置缩放级别和标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 12:30