8

In my App I've integrated the OpenStreetMap, in which I've fetched both source and destination coordinates. I need to pass those coordinates to OpenStreetMap App using Intent class, for that I need Uri.

After searching 2 days long I got this Uri

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

which currently supports only one location but I don't want it. Can anyone please help me with this? Thanks in advance...

Here is my code below

Intent sendLocationToMap = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://openstreetmap.org/?mlat=13.074847&mlon=80.271019&zoom=12"));
startActivity(sendLocationToMap);
Syakur Rahman
  • 2,056
  • 32
  • 40
Zakir Hussain
  • 414
  • 3
  • 13

2 Answers2

0

I assume you are asking about routing. In that case the answer is yes, there are various online routers (for example GraphHopper, OSRM and MapQuest) as well as offline routers for OSM available. Many of these online routers provide GPX exports.

scai
  • 20,297
  • 4
  • 56
  • 72
0

You need to use /directions endpoint.

Example (following intent will open www.openstreetmap.org website with route between two points):

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 app doesn't support directions urls:

OsmAnd will display only one geo point without route between them.

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


However Google Maps directions url:

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

is supported by Google Maps and HERE.

Ziem
  • 6,579
  • 8
  • 53
  • 86
  • I tried like the below one `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);` but it said "**Could not parse geo intent "http://www.openstreetmap.org/directions?engine=osrm_car&route=%13.06268%80.2653219%36427300%-99.27137000**" – Zakir Hussain Jun 16 '15 at 09:34
  • Which app do you use to open this intent? – Ziem Jun 16 '15 at 10:40
  • You know why I'm integrating OpenStreetMap instead of Google map, just because to support Blackberry devices as well(Since Blackberry doesn't support Google Maps). Is there any other way to do that? – Zakir Hussain Jun 16 '15 at 12:16
  • You need to ask OsmAnd developers if they are planning to support this kind of url. – Ziem Jun 16 '15 at 19:39