In my app, i want to open google map with specific location provided along with marker and its label with it. And i want to do this with 'Intent', not with 'Google Map' and 'Marker' classes. I am using the following code :
post_url.setOnClickListener({
val intent=Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse("https://www.google.com/maps/place/University+of+Oxford/@51.7548164,-1.2565555,17z/data=!4m12!1m6!3m5!1s0x4876c6a9ef8c485b:0xd2ff1883a001afed!2sUniversity+of+Oxford!8m2!3d51.7548164!4d-1.2543668!3m4!1s0x4876c6a9ef8c485b:0xd2ff1883a001afed!8m2!3d51.7548164!4d-1.2543668")
startActivity(intent)
})
It points to the provided location,but marker is not shown. I have also tried the following code:
post_url.setOnClickListener({
val intent=Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse("geo:0,0?q=51.7548164,-1.2565555(Oxford University)")
startActivity(intent)
})
In second method marker is visible but the label is not shown.The text 'Oxford university' is written on the bottom of map with info. But i want show with marker.See the following image to understand what i want.
Perhaps you can try the other options available for launching a google map using intent.
Double myLatitude = 51.7548164;
Double myLongitude = -1.2565555;
String labelLocation = "Oxford university";
1.
String urlAddress = "http://maps.google.com/maps?q="+ myLatitude +"," + myLongitude +"("+ labelLocation + ")&iwloc=A&hl=es";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlAddress));
startActivity(intent);
2.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<" + myLatitude + ">,<" + myLongitude + ">?q=<" + myLatitude + ">,<" + myLongitude + ">(" + labelLocation + ")"));
startActivity(intent);
3.
String urlAddress = "http://maps.googleapis.com/maps/api/streetview?size=500x500&location=" + myLatitude + "," + myLongitude + "&fov=90&heading=235&pitch=10&sensor=false";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlAddress));
startActivity(intent);
OR
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?q=<lat>,<long>(Label+Name)"));
startActivity(intent);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With