OpenStreetMap是否有用于Android的点(源)到点(目的地)方向URI?

8
在我的应用程序中,我集成了OpenStreetMap,并获取了起点和终点的坐标。我需要使用Intent类将这些坐标传递给OpenStreetMap应用程序,因此我需要Uri
在搜索了两天之后,我得到了这个Uri

http://www.openstreetmap.org/?mlat=latitude&mlon=longitude&zoom=12

目前仅支持一个位置,但我不想要。有人能帮我吗?先感谢了...

以下是我的代码

Intent sendLocationToMap = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://openstreetmap.org/?mlat=13.074847&mlon=80.271019&zoom=12"));
startActivity(sendLocationToMap);
2个回答

0

我猜你在问路由相关的问题。如果是这样,答案是肯定的,有各种在线路由器(例如GraphHopper、OSRM和MapQuest),以及可用于OSM的离线路由器。其中许多在线路由器提供GPX导出。


0

您需要使用/directions端点。

示例(以下意图将打开www.openstreetmap.org网站,并在两个点之间绘制路线):

http://www.openstreetmap.org/directions?engine=osrm_car&route=53.1855%2C18.0272%3B53.0915%2C18.0087

Intent sendLocationToMap = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://www.openstreetmap.org/directions?engine=osrm_car&route=53.1855%2C18.0272%3B53.0915%2C18.0087"));
startActivity(sendLocationToMap);

OsmAnd应用程序不支持方向URL:

OsmAnd将仅显示两个地理点之间没有路线的情况。

来源:https://github.com/osmandapp/Osmand/blob/master/OsmAnd-java/src/net/osmand/util/GeoPointParserUtil.java


然而Google地图方向URL:

http://maps.google.com/maps?daddr=53.0915,18.0087&saddr=53.1855,18.0272

被Google地图和HERE支持。


我尝试了类似下面的代码:Intent sendLocationToMap = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://www.openstreetmap.org/directions?engine=osrm_car&route=%"+ sourceLatitude + "%" + sourceLongitude + destinationLatitude + "%" + destinationLongitude)); startActivity(sendLocationToMap);但是它显示 "无法解析地理位置意图"http://www.openstreetmap.org/directions?engine=osrm_car&route=%13.06268%80.2653219%36427300%-99.27137000"**。 - Zakir Hussain
你使用哪个应用程序打开这个意图? - Ziem
你知道我为什么要集成OpenStreetMap而不是Google地图,只是因为要支持Blackberry设备(因为Blackberry不支持Google Maps)。还有其他的方法吗? - Zakir Hussain
你需要询问OsmAnd开发人员是否计划支持这种类型的URL。 - Ziem

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接