How geo URL Scheme link with multiple coordinates? - android

I'm trying to open a routing app (not google map) when user click on a link in android phone.
i don't want to use google map, so i make a link with geo URL Scheme like this:
<a href="geo:34,48">
and its work fine, but i want to make a link with multiple coords. for showing origin and destination coords on app.

I send second point with query parameter "q". now below link open routing applications like "here", with two origin and destination points. its work for two point but for more points i have no idea.
<a href="geo:34.80,48.50?q=34.81,48.52">

Related

How to lunch Google Map app from a react native app with a direction as coordinates

I am drawing a polyline on the MapView component from an array of coordinates that I am fetching from my backend server. There is a case when I want the user to open the installed Google Map on their android device with these coordinates and get directions based on that.
I know how to open the Google Map app with a single coordinate, like the following one:
const url = 'geo:37.484847,-122.148386';
Linking.openURL(url);
But, I am not sure (even have no idea if it is possible at all) how would I lunch the Google Map app with a bunch of coordinates and show them as a direction route (blue line).
As an example, If I have 3 points: A, B and C, I want to open the Google Map app and the app should display a direction route made using A to B and B to C.
Just got my answer. Sharing it in case anyone else face the same problem.
We just need to open this url: https://www.google.com/maps/dir/?api=1&parameters with the right parameters. In this case, waypoints. A collection of coordinates need to be passed using the pipe - | operator as the separator. The lat and lon should be separated by a comma.
Google has this documented here: https://developers.google.com/maps/documentation/urls/guide#directions-action
Great. To get the directions by deep linking you need to hit the API with the params as origin and destination . So check this https://www.google.com/maps/dir/?api=1&parameters and in place of params you can replace it with the proper params.
Google has perfectly documented here, google map direction
Hope it helps . feel free for doubts.

How can I control my direction type preference in the new Google Maps link URLs?

I would like to be able to have a Google Maps direction link which, when opened on mobile (Android), would bring up directions in Google Maps using a specified direction type (e.g. bicycle).
Using the old Google Maps URL parameters you can do,
https://www.google.com/maps/preview?saddr=[insert_from_address_here]&daddr=[insert_to_address_here]&dirflg=[insert_mode_here]
but it doesn't work on mobile.
Using the new Google Maps URL parameters you can do,
https://www.google.com/maps/dir/[customer address]/[our address]/am=t/
which does work on mobile but I don't know how to specify direction type.
From the Google Forum itself, try this on your URL if this works.
Car /data=!4m2!4m1!3e0
Bicycling /data=!4m2!4m1!3e1
Walking /data=!4m2!4m1!3e2
Public Transit /data=!4m2!4m1!3e3
Airplane /data=!4m2!4m1!3e4
For example
https://www.google.com/maps/dir/747+Howard+St,+San+Francisco,+CA/55+Music+Concourse+Dr,+San+Francisco,+CA/data=!4m2!4m1!3e3
For more information, juct check the link above and this stackexchange question.

PhoneGap direction using native Google Maps

I have an app containing a button which should present the user with directions to a local business. I wish to supply the directions using Google Maps with the inclusion of step-by-step road directions from the user's current location.
I wish for the native Google Maps app to handle the directions, but when I tried a href of https://maps.google.com/maps?q=..., Google Maps in opening the user's web browser, rather than in their Google Maps app.
This web-based map is not providing the step-by-step directions that I desire - it only provides an overhead view from point A to point B.
I have also tried
businesname
and
businessname
These hrefs do launch the native Google Maps app, but step-by-step direction are not shown.
In summary: how can I display a Google Map view to give step-by-step directions (preferably using the native app).
What you are looking for is called an intent. It is a command that passes some informations to an other app an can launch it.
What I would do is adding a method in your code that is called when the user touches the button. This method would be something like:
//Pass the link to the itinerary you want
void launchGMaps(String link) {
//Pass the link and the instruction to show something to an Intent
Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(link));
//Give the name of the app to start and the activity to start in this app.
myIntent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
//Gooooooooooo !
startActivity(myIntent);
}
I hope it helped.
F
If you DO NOT have inAppBrowser plugin loaded, you can do:
window.open("http://maps.google.com/maps?saddr=some+address&daddr=another+Address");
it will open a new browser window with the directions (but not the native app)
Or you can use the previous answer frouil, but to do so you must do the following.
In your main Java file, add, before the super.loadUrl call:
appView.addJavascriptInterface(this, "YouActivityName");
Then from your javascript, you use following method:
window.YouActivityName.launchGMaps("http://maps.google.com/maps?saddr=some+address&daddr=another+Address");
If you omit the saddr part android will try to use your current location and start address
You don't need any plugin.
Just Use this for any version of phonegap but don't use href in phonegap 3x.
Use window.open();
For Navigation -
window.open("google.navigation:q=23.3728831,85.3372199&mode=d" , '_system');
For Search -
window.open("geo:0,0?q=pizza" , '_system');
Read Here - https://developers.google.com/maps/documentation/android/intents

Starting Google Maps App with provided location and marker

From my app I would like to start the Google Maps App with a provided location and a marker. The marker should indicate, that there is something on that given location.
For now, I have the following code, which starts with an Intent the Google Maps App with the provided location (51.49234, 7.43045).
startActivity(
new Intent(
android.content.Intent.ACTION_VIEW,
Uri.parse("geo:51.49234,7.43045")));
When the Google Maps App starts, it looks like the following:
No marker is shown. I would like, that the Google Maps App would show a marker on that position, which is given through the Intent. Is there any "hidden" Intent URI's which I can use to show a marker within the Google Maps App?
Thanks in advance.
Solution
#Rajiv M. pointed me to the idea of querying the surroundings with the given location.
So, the solution is: Query the surroundings of your given location with your given location as the parameter. The URI looks like:
geo:51.49234,7.43045?q=51.49234,7.43045
Google Maps will show the query-result as the street name:
Kind of a hack, but it seems to work well.
Why you should not use 0,0 as the map location
geo:0,0?q=51.49234,7.43045
When you start Google Maps App with the provided map location point 0,0 , Google Maps App will start searching for your current device position. And this takes time. In some cases, when GPS signal is not provided, way too much. Until then the Google Maps App will start searching for your query 51.49234,7.43045.
Try starting Google Maps using the same intent, but with a URI of the format:
geo:34.067214,-118.349332?q=410+Hauser+Boulevard,+Los+Angeles,+CA
i.e. geo:0,0?q=street+address
The application should then actually show a point at that address. If you do not have the address, you may have to use a service to translate it to an address for this to work.
-
The other option is to embed a MapView in your application and add a marker within that. A tutorial for using MapViews / Markers with-in your application can be found at http://mobiforge.com/developing/story/using-google-maps-android.
Maybe you can try to put ur uri as below:
Uri uri =Uri.parse("http://maps.google.com/maps?q=" +_lat +","+_lon);
At least the above code work for me. It help me add a pin point on top of the location i search for. furthermore, the pin point will have a small dialog box to press on, it provide me the function of searching the direction to that location. :D

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

i don't wanna use a MapView an some Overlays. I only want to use the given intent Google Maps. Showing a Adress in Google Maps works fine when i call it from my application using Uri.parse("geo: ...") ... But i only see the map centered at the given adress. There are no marker or "bubble" like they are when i do a search in google maps. I can define the Zoom in the Uri with "z=12" ... Is there one thing i had to set up to see the marker and the "bubble"?!
Thank you!!!
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.

Categories

Resources