谷歌地图V2 - 意向URI参数 [英] Google Maps v2 - Intent URI Arguments
问题描述
我通过发起一个Intent内置的地图应用(7.1.0),但是,没有请求URL的我送它似乎是工作的。
I'm launching the builtin Maps app (7.1.0) via an Intent, however none of the request url's I'm sending it seem to be working.
我想知道正确的语法是什么样的URL / URI参数。
I was wondering what the correct syntax is for the url/uri argument.
我认为这是一个静态地图请求,但内置的地图应用程序是不是一个静态的地图,并且可能是为什么他们不工作。
I thought it was a static-map request, but the built-in map app isn't a static map, and is probably why they do not work.
旧式V1请求字符串不工作的。
The older style v1 request strings do not work either.
它甚至有可能通过,因为V2一个URL / URI参数意图将请求发送到地图应用程序?
Is it even possible to send requests to the map app via a url/uri intent argument since v2 ?
任何帮助或提示将不胜AP preciated(我只是想用内置的地图应用程序,觉得我不应该实现自己的MapActivity /片段,因为我没有做任何事情花哨,只是一个简单的图)。
Any help or tips would be greatly appreciated (I just want to use the built-in map app, and feel I shouldn't have to implement my own MapActivity/Fragment, since I'm not doing anything fancy, just a simple plot).
下面是code触发该图:
Here is the code that fires the map:
//string url = "http://maps.googleapis.com/maps/api/staticmap?geo:50.95144,6.98725?q=50.95144,6.98725%20(Disneyland)&zoom=13&size=600x300&sensor=true";
//string url = "http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&sensor=true";
string url = "http://maps.googleapis.com/maps/api?center=Brooklyn+Bridge,New+York,NY";
Uri uri = Uri.Parse( url );
Intent intent = new Intent(Android.Content.Intent.ActionView, Uri.Parse(url));
intent.SetClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
StartActivityForResult(intent, 0);
感谢您。
推荐答案
只要指定在查询参数并他们的价值观,并省略 URI方案(HTTP:// ),服务器名称(maps.googleapis.com)和资源路径(/地图/ API)。
Just specify the query parameters and their values, and omit the uri scheme (http://), server name (maps.googleapis.com) and resource path (/maps/api).
不过,该中心参数似乎并没有工作(我反正)
However, the center param doesn't seem to work (for me anyway)
string url = "center=Brooklyn+Bridge,New+York,NY"
使周围的工作,我用的是地缘和q PARAMS一起
so as a work around, I use the geo and q params together
string url = "geo:0,0?q=Brooklyn+Bridge,New+York,NY";
或
string url = "http://maps.google.com/maps?q=new+york";
这篇关于谷歌地图V2 - 意向URI参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!