How to Show a Marker in Maps Launched by Geo Uri Intent

How do I show a marker in Maps launched by geo URI Intent?

Try this:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?q=<lat>,<long>(Label+Name)"));
startActivity(intent);

You can omit (Label+Name) if you don't want a label, and it will choose one randomly based on the nearest street or other thing it thinks relevant.

showing the marker in Google Maps using Intent -- Uri.parse(geo: ...)

Is there one thing i had to set up to see the marker and the "bubble"?!

There is no documented and supported means to put a "marker" or "bubble" when you use a geo: URL. Bear in mind that it might not be Google Maps that winds up responding to that URL -- the user could have installed another mapping application that they choose to handle such requests.

how to Intent to particular location in google maps with marker on it?

Try this sample for launching google maps with specific Lat & Lng

public void gotToLocation(String markerName,Float latitude, Float longitude ) {
String uri = String.format(Locale.ENGLISH, "geo:0,0?q=%f,%f(%s)", latitude,longitude,markerName);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));;
mapIntent.setPackage("com.google.android.apps.maps");
if (mapIntent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivity(mapIntent);
}
}

then call it like this

gotToLocation("MyLocation",34.99,-106.61);

Android - How to launch Google map intent in android app with certain location, zoom level and marker

Try the following solution:

double latitude = 40.714728;
double longitude = -73.998672;
String label = "ABC Label";
String uriBegin = "geo:" + latitude + "," + longitude;
String query = latitude + "," + longitude + "(" + label + ")";
String encodedQuery = Uri.encode(query);
String uriString = uriBegin + "?q=" + encodedQuery + "&z=16";
Uri uri = Uri.parse(uriString);
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
startActivity(intent);

Credit goes here: Answer

I believe the problem had to do with the spaces in your label. Encoding the query string will eliminate the issue by replacing the spaces with valid characters

Intent to launch map with current location for placing markers

this is my GPS class

public class GPS {

private static final TAG = "GPS";
private static boolean pGps, pNetwork;
private static LocationManager locManager;
private static String provider;
private static double longitude;
private static double latitude;

private static void updateAvailability(){
try {
pNetwork = locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
provider = LocationManager.NETWORK_PROVIDER;
} catch (Exception ex) {
Log.w(TAG,"Ex getting NETWORK provider");
}
try {
pGps = locManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
provider = LocationManager.GPS_PROVIDER;
} catch (Exception ex) {
Log.w(TAG,"Ex getting GPS provider");
}
}

public static Location getLastLocation(Context ctx){
Location loc = null;
if(ctx != null){
if(locManager == null){
locManager = (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE);
}
updateAvailability();
if(provider!=null){
loc = locManager.getLastKnownLocation(provider);
}
}
return loc;
}

}

Now from you button you can show the map with the right latitude and logitude.

Button placeMarkerButton = (Button) findViewById(R.id.bLaunchMaps); 
placeMarkerButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
Location loc = GPS.getLastLocation(this.getApplicationContext());
Double myLongitude = loc.getLongitude();
Double myLatitude = loc.getLatitude();
//using google maps you will create a map setting lat & long.
String urlAddress = "http://maps.google.com/maps?q="+ myLatitude +"," + myLongitude +"("+ title + ")&iwloc=A&hl=es";
//second option:: urlAddress = "http://maps.googleapis.com/maps/api/streetview?size=500x500&location=" + myLatitude + "," + myLongitude + "&fov=90&heading=235&pitch=10&sensor=false";
//third option:: urlAddress = "geo:<" + myLatitude + ">,<" + myLongitude +">?q=<" + latitude + ">,<" + longitude +">(this is my currently location)"
Intent maps = new Intent(Intent.ACTION_VIEW, Uri.parse(urlAddress)));
startActivity(maps);
} catch (Exception e) {
Log.e(TAG, e.toString());
}
}
});

How to launch map intent with a marker/overlay item at given latitude and longitude?

You can use it like,

Showing Particular Place,

Uri uri = Uri.parse("geo:0,0?q=22.99948365856307,72.60040283203125
(Maninagar)");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

Showing Route between to Places,

Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr="+23.0094408+","+72.5988541+"&
daddr="+22.99948365856307+","+72.60040283203125));
startActivity(intent);


Related Topics



Leave a reply



Submit