Starting Google Maps App with provided location and marker - android

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

Related

Is it possible to draw a path of coordinates and navigate between them, using Google Maps or other apps?

This is a simple question.
I know it's possible to request to navigate to a specific place, as shown here.
I know there are also some other APIs for Google Maps (here and here), but I don't see an option to send multiple coordinates, to see the path between them, and navigate between them.
For the Web version, there is the ability for waypoints (example here and here), but not for Android.
Is it possible to do it, via Google Maps, or another app?
Or maybe even in the Google Maps API (within the current app) ?
Since V3 Google Maps Directions API support up to 23 waypoints (excluding the origin and destination) when calculating routes:
https://maps.googleapis.com/maps/api/directions/json?origin=sydney,au&destination=perth,au&waypoints=via:-37.81223%2C144.96254%7Cvia:-34.92788%2C138.60008&key=YOUR_API_KEY
So, you can draw polyline with up to 23 points and send they coords in request.
UPDATE:
Please see this tutorial.
UPDATE 2:
Example opening navigation mode of Google Maps app for route Tel-Aviv to Jerusalem via Kiryat Malakhi, Beit+Guvrin and geopoint (31.696342, 35.011337) via Intent:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("https://www.google.com/maps/dir/?api=1&" +
"origin=3780+St+1,+Tel-Aviv+Yafo,+Israel&destination=Jerusalem,+Israel&travelmode=driving" +
"&waypoints=Kiryat+Malakhi,+Israel%7CBeit+Guvrin,+Israel%7C31.696342, 35.011337"));
startActivity(intent);
Result:
Parameter details here.

Google Plus - share map or positions

I'm getting familiar with Plus API, I have successfully posted string on my google plus via:
Intent intent = new PlusShare.Builder(this)
.setType("text/plain")
.setText("Hi all")
.setContentUrl(Uri.parse("http://plus.google.com"))
.getIntent();
startActivityForResult(intent, PLUS_INTENT_RESULT);
But I wasn't able to find a way to post a GoogleMap or locations, or mark a postition on map. But I can't add a map to a web google plus:
Ass you can see, there's no add map or location
there is only Link possibility but I want to display map like in Hangouts
]
Could you give me some hint? Thank you.
The code that you are using utilizes the Google Plus framework API. There is no way you can modify them in order to get the Maps or location to be shared.
But yes, as you mentioned there are other long routes that you can take in order to share user's location or even maps.

Mobile web driving directions from current location

I'm building a mobile-version of a website, trying to have one-click link to launch Google Maps with driving directions to the business, from the user's current location. I have it working fine for the iPhone, but when testing on Android, it views 'Current%20Location' and tries to find a business called 'Current Location'. Here is my current code:
Get Directions
I need a universal string to search from the current location, and can't find a definitive answer anywhere online.
Thanks in advance for any help!
I am doing the same thing and now have it working on Android. I don't have an iPhone so I have no way of testing on that. You should leave the saddr parameter blank in the URL, and Google Maps will then prefill it with the user's current location. Also, use + signs instead of spaces in the destination address. Here's the corrected URL:
http://maps.google.com/maps?saddr=&daddr=123+Street+Rd,Cityville,MD,21098
Use the google gps api to get the currentlocation and pass it to maps. Even better I think there's an action to open the built-in maps application asking it to route from current location to your address.
This article on location services should help http://developer.android.com/guide/topics/location/index.html
If you're trying to do it fully through the web, I think the user has to enable location services on the google webpage for it to work.
Also, check out this javascript library that provides a platform neutral api for gps services on most devices http://code.google.com/p/geo-location-javascript/
Google Maps with directions from current location
https://maps.google.com/maps?saddr=&daddr=35.658157,139.697174&sensor=TRUE
https://maps.google.com/maps?saddr=&daddr= PLUS
"location's_latitude" PLUS
"," PLUS
"location's_longitude" PLUS
"&sensor=TRUE" // for getting your current location
Probably the most accurate way using lat and long
<span class="addressAt">
<a href="http://maps.google.com/maps?f=d&hl=en&region=US&doflg=ptm&geocode=&saddr=&daddr=41.75553,-88.322048" target="_blank">213 S River St
Aurora, IL</a>
</span>
This is the only way to get an accurate "my location" on the google maps mobile site. Replace the coordinates(41.75553,-88.322048) with your locations coords. All other ways just wrote in my location as the start address without actually getting the real time location.

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.

how to view the map in an android app

in my app i want to show the location address, latitude and longitude and exact position of the user in the map.
i am able to find the latitude and longitude. In my app i have a button named "View Map", when the user click on it i want to show the location in a map. Is it possible to open the google maps or maps which is in present in the android devices when i click on the button, if not what is the option please help me...
You can either show a map inside your own activity as written in the previous answer's link or you can fire an intent to open the Google Maps application in your device. You can find the relevant intent here: http://developer.android.com/guide/appendix/g-app-intents.html
To start with showing Map in your Activity begin with http://developer.android.com/guide/tutorials/views/hello-mapview.html
And to show your location in attractive manner use https://github.com/jgilfelt/android-mapviewballoons

Categories

Resources