I'm designing one application in which I want to show specific location on Map.
I'm passing String
of address which is already placed on Google Map
.
Following is my Intent
code..
String url = "http://maps.google.com/maps?daddr="+address;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
But it gives me Google Map for getting direction. I know why that so, because I used daddr
in url
but I don't know what to use for specific location..Please tell me what to use there..
You should use something like this
And to drop a pin
The latest version of map provides better solution. If you wish show an address on map use below code.
If you want to display using latitude and longitude values, use below method.
Lat and lng being the latitude and longitude you wish to display, the label here is optional.
I have not tested this but you could try :
First method:
EDIT: This might not work with Google maps 7,0
hence you could change the uri to :
Second option:
where
mTitle
is the name of the location.Third option:
Fourth option:
Hope that works and helps :D..
Get Lat-Lng Using this web-service
http://maps.google.com/maps/api/geocode/json?address=" + address + "&sensor=false
Then Pass it to this code
I hope it will help you
Thank you.
This will work like a charm. Make sure to check for existence for Google Maps, so this can work universally across all non Google devices also. It will open in browser in such cases.
Also remember dont have www in the URL. Else this will not work.
Refer this documentation