1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
   | 	public void startIntentToGoogleMap(LatLng latlng, String labelTo)
	{
 
		 String uri = String.format(Locale.FRENCH, "http://maps.google.com/maps?&daddr=%f,%f (%s)", latlng.latitude, latlng.longitude, labelTo);
 
	        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
	        intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
	        try
	        {
	            startActivity(intent);
	        }
	        catch(ActivityNotFoundException ex)
	        {
	            try
	            {
	                Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
	                startActivity(unrestrictedIntent);
	            }
	            catch(ActivityNotFoundException innerEx)
	            {
	                Toast.makeText(this, "Please install a maps application", Toast.LENGTH_LONG).show();
	            }
	        }
	}
 
	public void startIntentToGoogleStreeView(LatLng latlng, String labelTo)
	{
 
 
		 	Intent intent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("google.streetview:cbll="+ latlng.latitude+","+latlng.longitude+"&cbp=1,99.56,,1,1&mz=21"));
 
 
 
	        intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
	        try
	        {
	            startActivity(intent);
	        }
	        catch(ActivityNotFoundException ex)
	        {
	            try
	            {
	            	String uri = String.format(Locale.ENGLISH, "http://maps.google.com/maps?&daddr=%f,%f (%s)", latlng.latitude, latlng.longitude, labelTo);
	                Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
	                startActivity(unrestrictedIntent);
	            }
	            catch(ActivityNotFoundException innerEx)
	            {
	                Toast.makeText(this, "Please install a maps application", Toast.LENGTH_LONG).show();
	            }
	        }
	} | 
Partager