Gmail中是否提供了“Map this”功能?

时间:2014-10-30 13:07:13

标签: google-maps google-api

有人知道Google提供的Gmail“Map this”功能可用于API。我研究了很多,但没有找到理想的结果。我想要提供字符串消息的Google API:

BREA PROBLEM F:830 N MAIN ST 46, MT ANGEL:R454,
MED23:MAP-2530C:57YOF/ C/DIFFB  BEE STING:BAVARIAN VILLAGE    503 845-2586::

Google会返回结果,就像“映射此”功能一样:

http://maps.google.com/maps?q=830+N+MAIN+ST+MT+ANGEL,+OR&oi=gmail

以下是更好地理解我的问题的图片:

Gmail "Map this" screenshot

2 个答案:

答案 0 :(得分:2)

Google Maps API

您可以使用Google Geocoding API完成“映射此功能”功能。更准确地说,您正在尝试geocode a given address

  

地理编码是将地址(例如“1600 Amphitheatre Parkway,Mountain View,CA”)转换为地理坐标的过程   (如纬度37.423021和经度-122.083739),您可以使用   放置标记或定位地图。

您可以在此处找到一个简单的实时地理编码示例:https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple

最终,它会显示您在URL之后。似乎没有提供URL的API请求的显式返回。但是,如果您从请求中收到以下status code,则可以轻松创建URL:

google.maps.GeocoderStatus.OK indicates that the geocode was successful.

手动URL创建

或者,您可以使用给定地址创建URL。例如,如果给定的地址是1500 Red Oak Drive,请将该字符串连接到http://maps.google.com/maps?q=,Google地图将解析为匹配或显示可能的匹配。

以下是我编写的一些虚假地址。第一个实际存在,GMaps找到它。第二个没有,GMapgs提供了一些可能的匹配。

Static Maps API V2开发人员指南

Static Maps API还可以为您提供有关如何根据给定地址构建网址的建议。

答案 1 :(得分:0)

您只需将地址转换为Google lang和纬度地址:

最佳和有保证的手动URL创建有两个步骤

第1步: 获取您的地址 使用LocationManager。

LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double longitude = location.getLongitude();
double latitude = location.getLatitude();
The call to getLastKnownLocation() doesn't block - which means it will return null if no position is currently available - so you probably want to have a look at passing a LocationListener to the requestLocationUpdates() method instead, which will give you asynchronous updates of your location.

private final LocationListener locationListener = new LocationListener() {
    public void onLocationChanged(Location location) {
        longitude = location.getLongitude();
        latitude = location.getLatitude();
    }
}

lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 10, locationListener);
You'll need to give your application the ACCESS_FINE_LOCATION permission if you want to use GPS.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
You may also want to add the ACCESS_COARSE_LOCATION permission for when GPS isn't available and select your location provider with the getBestProvider() method.

第2步: 在Google网址中插入Lang和lat 像这样的东西

String url = "https://www.google.co.in/maps/place/"+ Langitude +","+ Lattitude;

您可以使用此网址执行任何操作,例如将其提供给webview或打开谷歌地图。或者使用谷歌嵌入式地图启用它,或者只是将此字符串作为邮件发送

相关问题