Reputation: 1871
I'm trying to get direction from my location to the provided address in android Google map v2, for that I'm using following code.
String daddr = AddressLine1() + " " + AddressLine2() + " " + City() + " " + Pincode();
Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr=" + "" + "&daddr=" + daddr));
startActivity(i);
in above code "saddr=" its blank, so its always takes current location but in "daddr=" is taking partial address, like if the address is "Dcusa Inc, US Highway 22, Mountainside, NJ, United States"
, its will takes only "Dcusa Inc, "
this much and ask autocomplete. But I want to take full address. I've debug the code before sending daddr data to activity its showing full address. I don't know what to do now, please help me how can I trigger it..
Upvotes: 0
Views: 1165
Reputation: 4661
Direcly you cant do that. First you have to get the latitude and longitude of the source and destination address.You can refer the below mentioned link to get co-ordinates. TO Get geopoints using address
From this reference you will get latitude and longitude and you can pass the values to maps url using intent. then it will work.
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=xx.xx,xx.xx&daddr=xx.xx,xx.xx"));
startActivity(intent);
here xx.xx means latitude and longitude.
Upvotes: 1
Reputation: 3400
Maybe it is because of space. You need to URL encode the address string as it will be a parameter in the maps URL to be valid
Upvotes: 0