Launching Driving Directions with Lat and Long values from another activity - android

Here's my situation:
I have a list that will launch different pages for different places.
Each of these pages already have a WebView and MapView showing the
details and the map of the respective places (I used a TabHost)
I created an activity which extends ItemizedOverlay to enable me to place a marker, as well as to launch an alert dialog for my driving directions. This is used by all the MapView
I am able to launch driving directions from the alert dialog through the Google Maps app from my app so far. However, I have to put the lat and long values (actual numbers) in the Uri.parse("http://maps.google.com/maps...").
Is there a way to replace the lat and long values with strings from the Activity of the respective places?
P.S. Please pardon me as this is my first time posting here, and I am very new to programming =)

Try something like this:
String uri = "http://maps.google.com/maps" + String.format( "?daddr=%s,%s",
getLocationLat(),
getLocationLng() );
Intent i = new Intent( Intent.ACTION_VIEW, Uri.parse( uri ) );
startActivity( i );

Related

How do I create a button that brings you to the Google Maps app at a specific location?

I have a simple android button
<Button
android:id="#+id/btnTakeMeThere"
android:background="#00FF00"
android:text="Take me there!"
...
/>
My app contains some information inside my activity about a place the user should go, stored as latitude and longitude.
I would like this button to bring the user to the Google maps app and go to that location.
How do I do this?
So far I've added an onclick listener to the button (I'm using Kotlin)
var latitude, longitude: Float;
btnTakeMeThere.setOnClickListener {
}
Uri uri = Uri.parse("geo:[lat],[long]?z=17[zoom]&q=[text]");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

Adding waypoints to navigate in waze map

In my application i want implement waze map navigation for multiple destination,i just achieved single origin and destination navigation ,but here i want to navigation multiple waypoints.
String url = String.format("waze://?ll=" + Double.parseDouble(_Lat) + "," + Double.parseDouble(_Long) + "&navigate=yes");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
I'm looking for a solution to the exact same problem.
Looks like they don't wish to provide - clueless why they are afraid people would use that.
Anyway, would it be possible that the activity which opened the intent also has a simple GPS listener which calculates when you're (almost) reached (or passed) your waypoint, and set the next coordinates (in the opened intent / or new one) ...?
For now I'm using google maps with a full URL, still I wish to send my users straight into navigation, not a browserwindow that may have or may not have a navigation button (Chrome versus other browsers).
A simple A to B is not working for me, I need a "A B C, break, C B A".

How to integrate current locatioon in android project mapview balloons

I'm trying out the info balloon from: https://github.com/jgilfelt/android-mapviewballoons and it's working perfectly. One thing I'm missing is the ability of setting the current location. Does anybody know how to precisely implement that function?
Thanks in advance !
Yes, for example I have some url variable which I display in baloon and my onBaloonTap looks like this, where c is context
#Override
protected boolean onBalloonTap(int index, OverlayItem item) {
String url = WebService.upcomigEvent;
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
c.startActivity(i);
return true;
}
You can track position by implementing the LocationListener interface, or by using the MyLocationOverlay class. In both, the method onLocationChanged is available, and you can provide it with your own location object that you create, specifying the lat/lng/alt. This in effect 'spoofs' the users location, and this might not be what you want. If you just want to scroll the map to a specific point you can use the animateTo method available in the MapController.

Google maps: change from satellite view to street view

I want to to change the google map view from one state to another. Currently the view is satellite view, now I want to change it to street view. I have written as below but it's not changing the view. How do I change the view at run-time?
mapView.setStreetView(true);
After that put this line and let me know what happen,
mapView.invalidate();
In your code you have to do something like,
mapView.setStreetView(true);
mapView.setSatellite(false);
mapView.invalidate();
Uninstall the project from the emulator and again run it.It hope it will work.
As the MapView reference shows, setStreetView does not change the map to street view - it only toggles showing the blue streaks indicating whether street view is available or not, on the map position you're currently looking at. I would guess that the easiest way to start street view is to start google's own street view app via StartActivity.
mapView.setStreetView(true);
Is depreciated.
try {
Intent streetView = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("google.streetview:cbll="+my_lat+","+my_lng+"&cbp=1,99.56,,1,-5.27&mz=21"));
streetView.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(streetView);
} catch ( Exception ex ) {
Toast.makeText(getBaseContext(), "Could not launch Goole Street View. Are you sure it's installed? Launching market...", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=com.google.android.street"));
startActivity(intent);
}
Without the try/catch your app will crash if street view isn't installed.
See this possible duplicate
mapView.setStreetView(true);
mapView.setSatellite(false);
mapView.invalidate();

Android Maps Intent - Extra Parameters

Right now, I'm launching the Google Maps application with the following call:
String geoAddress = "maps.google.com/maps?q=";
geoAddress += LatLong[0] + "," + LatLong[1];
Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(geoAddress));
startActivity(i);
Which will open and place a marker at the specified position on the map. I have two questions:
1) How can I place multiple markers of which I have the Longitude/Latitude?
2) How can I start the Maps application to other modes (terrain/satellite/etc.)?
Thanks!
you can add multiple links on the map by using overlays,and u can see the GoogleMapview example in http://developer.android.com/resources/tutorials/views/hello-mapview.html.
here you can understand use of overlays.
Read the following links and download the code the link(For Further reference)
https://github.com/jgilfelt/android-mapviewballoons
https://github.com/jgilfelt/android-mapviewballoons#readme
2.To change the views use following functions,
mapView.setSatellite(true);
mapView.setStreetView(true);
For further reference
http://mobiforge.com/developing/story/using-google-maps-android

Categories

Resources