Search code examples
androidgoogle-mapslatitude-longitudedirection

how to know google map could not calculate directions from place a to place b in android


i want to show direction from place A to place B, by using google map application and intent

  1. at first i find latitude and longitude of both places
  2. then i use below URL to show the direction between 2 places

    "http://maps.google.com/maps?saddr=" + lat1 + "," + lng1 + "&daddr=" + lat2 + "," + lng2

it;s OK and all things goes right but s.times google map can't find direction and it shows below error

Sorry, we could not calculate directions from place A to place B

i read about this error and understood that

the directions is not supported in every country of the world

but , here is my question that how can i get this error to show users, my own sentence instead of opening google map application with intent and then google map shows this to users

UPDATE : here is the URL , u can test it
it will show "Sorry, we could not calculate directions"


Solution

  • You can integrate Google Maps rest api. More about it here You can use status codes from the response