Getting nearby location or Landmarks - android

Is there any API in google for finding nearby location or Landmarks for my current GPS lat&long position.

Use this :
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=business+near+city");
startActivity(intent);
After geo you put your coordinates, and after q= you input your search tearms, like tourism+city. This will fire up the Google Maps app with the points of interest.
If you want to use a maps view inside your application, you would need to get the data from some service, like your own. However you could pull the data from Google's ajax search like this
http://ajax.googleapis.com/ajax/services/search/local?v=1.0&rsz=large&gl=pl&q=tourism+chicago
more info :
http://code.google.com/apis/websearch/docs/reference.html#_fonje_local
This will give you results that have geo-coordinates and you would need to make a way of parsing the results and maybe get them into a database.
hope it helps...

Related

Google Maps Navigation in Android

I am working with Android and building an app that wants to navigate between 2 points. I already have the points with me. I have the route between them as well on google maps. I just want to navigate between them. Could you please help me on this?
Consider you have two locations source, destination, The below code will redirect you to google navigation, Make it as a method and call when ever you want!.. Let me know if you need any other help
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://ditu.google.cn/maps?f=d&source=s_d" +
"&saddr="+source.getLatitude()+
","+source.getLongitude()+"&daddr="+
destination.latitude+
","+destination.longitude+
"&hl=zh&t=m&dirflg=d"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
startActivityForResult(intent, 1);
You can try to use Directions API.
The Google Maps Directions API is a service that calculates directions between locations using an HTTP request.
This service is generally designed for calculating directions for static (known in advance) addresses for placement of application content on a map, however this service is not designed to respond in real time to user input.
A Google Maps Directions API request takes the following form:
https://maps.googleapis.com/maps/api/directions/output?parameters
where output may be either of the following values:
json (recommended) indicates output in JavaScript Object Notation (JSON)
xml indicates output as XML
To access the Google Maps Directions API over HTTP, use:
http://maps.googleapis.com/maps/api/directions/output?parameters
HTTPS is recommended for applications that include sensitive user data, such as a user's location, in requests.
You need this parameter in getting the directions:
origin - The address, textual latitude/longitude value, or place ID from which you wish to calculate directions.
destination - The address, textual latitude/longitude value, or place ID to which you wish to calculate directions. The options for the destination parameter are the same as for the origin parameter, described above.
Check also this tutorial for more information.
It's working fine.
String uri = "http://maps.google.com/maps?f=d&hl=en&saddr="+startingLocation.latitude+","+startingLocation.longitude+"&daddr="+destinationLocation.latitude+","+destinationLocation.longitude;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(Intent.createChooser(intent, "Select an application"));

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.

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

Get surrounding location details using GPS?

I'm new to Android; I'm able to get the current location using GPS but how do I get the surrounding location details using the current location obtained? Please guide me.
Use this :
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=business+near+city");
startActivity(intent);
After geo you put your coordinates, and after q= you input your search tearms, like tourism+city. This will fire up the Google Maps app with the points of interest.
If you want to use a maps view inside your application, you would need to get the data from some service, like your own. However you could pull the data from Google's ajax search like this
http://ajax.googleapis.com/ajax/services/search/local?v=1.0&rsz=large&gl=pl&q=tourism+chicago
more info :
http://code.google.com/apis/websearch/docs/reference.html#_fonje_local
This will give you results that have geo-coordinates and you would need to make a way of parsing the results and maybe get them into a database.
hope it helps...

Android Google Directions Service usable natively? with wrapper framework? Public transit/biking directions available?

Some questions about Android and Google Directions Service:
Is there a native way on Android to use the Directions Service from Google or are there any nice Wrapper Frameworks?
I would like to retrieve the time needed to get from A to B and maybe show the route in a table and/or map.
As far as I know directions can only be retrieved for "walking" and "driving". Is there a way (maybe not from google) to get this Information also for public transports or "biking" ?
I don't know exactly if this is what you want, but you could fire up an intent like this:
String url = "http://maps.google.com/maps?saddr=some+address&daddr=another+Address"
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
To get biking directions add "&dirflg=b" to the url. For public transport add "dirflg=r".
This will display the route in the google Maps app. If you want to get this in your app inside a mapview, please see this code at github. You could hack into the code to add biking and public transport functionality.
Hope this helps somehow.

Categories

Resources