Using location based services from my app - Android - android

I want to show local points of interest to the users.
Since this isn't the main goal of my app, I wish to find a rather simple solution,like sending the user to Google Places or any other location based app.
Is there a way of doing that?
If the answer is no, how could I do that? Maybe using some API?
Thanks

You can use the android location and maps api documented here. If not, you can always call the Maps intent but you have to make sure google maps is installed before using it. Here is an example using the Location api from the android dev page linked here:
// Acquire a reference to the system Location Manager
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
// Define a listener that responds to location updates
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
// Called when a new location is found by the network location provider.
makeUseOfNewLocation(location);
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
Now register your application with google API here. Once you get your API key you can use an http request to https://maps.googleapis.com/maps/api/place/search/json?location=&radius=&types=&name=&sensor=&key=YOUR_API_KEY.
You can find the definition of each parameter from the google maps api site here but this is a little list:
location (required) — The latitude/longitude around which to retrieve Place information. This must be provided as a google.maps.LatLng object.
radius (required) — The distance (in meters) within which to return Place results. The recommended best practice is to set radius based on the accuracy of the location signal as given by the location sensor. Note that setting a radius biases results to the indicated area, but may not fully restrict results to the specified area.
types (optional) — Restricts the results to Places matching at least one of the specified types. Types should be separated with a pipe symbol (type1|type2|etc). See the list of supported types.
language (optional) — The language code, indicating in which language the results should be returned, if possible. See the list of supported languages and their codes. Note that we often update supported languages so this list may not be exhaustive.
name (optional) — A term to be matched against the names of Places. Results will be restricted to those containing the passed name value. When a name is included, the area being searched may be broadened, to ensure a suitable number of results.
sensor (required) — Indicates whether or not the Place request came from a device using a location sensor (e.g. a GPS) to determine the location sent in this request. This value must be either true or false.
key (required) — Your application's API key. This key identifies your application for purposes of quota management and so that Places added from your application are made immediately available to your app. Visit the APIs Console to create an API Project and obtain your key.
Here's a quick HTTP request example in android:
HttpGet myGet = new HttpGet("https://maps.googleapis.com/maps/api/place/search/json?location=&radius=&types=&name=&sensor=&key=YOUR_API_KEY");
Once you got your return result, you can parse the response using any json library such as google-gson from here.
Ryan

Your question is not clear but from your question i am able to know that you want to display location of user interest correct me if i m wrong.
if you want to same then
1) you need latitude and longitude of that points
for that you can use any API of you can get those from your webservice
2) after getting list of latitude and longitude you can display those on map by using Itemized Overlay

Related

GPS Location Data Not Correct Display on Google Map

i'm setting a new project in flutter with flutter_google_maps for tracking user location on map it's a basic project
But when i am moving devices or ride then my Location are point on map but not right place
Ex.
I am walk on street road then google map navigation show exact my
location But my project not show exact location
Code are normal just use Flutter Location Plugin
And Track Location Using this code
location.onLocationChanged().listen((LocationData currentLocation) {
print(currentLocation.latitude);
print(currentLocation.longitude);
});
And set to marker target value describe in google_maps_flutter
i google lot of things but no answer found who resolve my problem
Where I'm wrong ya any other methods use by other location tracking app
Thanks

Making a map on android

im trying to make an app on android just a typical map that utilizes a smartphones GPS and i am planning on using Dijkstra’s shortest path algorithm.
What i plan to do is make a top view map of an island and gather latitude and longitude data for each intersection on the islands road from my gps, join the image (the map of the island i made) with the latitude and longitude data then implement Dijkstra’s shortest path algorithm.
any suggestions?
how will i go about this?
first
Activity file
GoogleMap googleMap;
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
Follow the Getting Started
This guide is a quick start to adding a map to an Android app. Android Studio is the recommended development environment for building an app with the Google Maps Android API.
Step 1. Download Android Studio
Step 2. Install the Google Play services SDK
Step 3. Create a Google Maps project
Step 4. Get a Google Maps API key
Step 5. Hello Map! Take a look at the code
Step 6. Connect an Android device
Step 7. Build and run your app
Enabling GPS:
#Override
protected void onStart() {
super.onStart(); // Always call the superclass method first
// The activity is either being restarted or started for the first time
// so this is where we should make sure that GPS is enabled
LocationManager locationManager =
(LocationManager) getSystemService(Context.LOCATION_SERVICE);
boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (!gpsEnabled) {
// Create a dialog here that requests the user to enable GPS, and use an intent
// with the android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS action
// to take the user to the Settings screen to enable GPS when they click "OK"
}
}
Hope this helps!

How can I get all Facebook public events those locations ids are same to the specific given location id using Facebook Graph Api?

Right now, I'm getting nearby events(but not all the list) on the basis of following two graph api call:
First (getting nearby location ids):
search?q=*&type=place&center=lat,long&distance=50000&
limit=10000&fields=id,name
Second (and getting events from those location ids):
?ids=275177672565817&fields=events.fields(id,name,description,start_time,attending_count)
But the problem is, I'm not getting all the nearby public events because it just gives me only those events which are hosted by that Facebook location page.
I need all events either it is hosted by that location page (whose location id I've found) or by someone else who is just having same location id of his/her event.
Can anybody tell me that is there any way to do this?
May be you would be able to do this, if you have created your app before April 2014? Using FQL, see the following answer
https://stackoverflow.com/a/22373119/5212599

How to use google maps script for android

How do i use the google maps on android to get the same script as the website
I want it to search the nearest mcdonalds from the location and have all the markers from the website
https://mcdonalds.com.au/find-us/restaurants
That is possible. You can do that using Google Places API and specify in the parameters for types=restaurants.
This is a tested example:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=cruise&types=restaurant&key=YOUR_API_KEY
Now this will fetch all the restaurants in the radius you have defined in the proximity of your current location or the input location.
You can further filter results by writing code that checks if {name name = Mc Donalds} then only fetch the results else {do nothing}. This would give you results just for McDonalds in 500 meter of radius from the specified location.
Hope this Helps!!

Google Maps Android API v2 - APIs related to my location deprecated. Why?

Since the Google I/O 2013 we can read in several places of the documentation of Google Maps Android API v2 that
This method / interface is deprecated.
use com.google.android.gms.location.LocationClient instead. LocationClient provides improved location finding and power usage and is used by the "My Location" blue dot. See the MyLocationDemoActivity in the sample applications folder for example example code, or the Location Developer Guide.
While it is great the new API appeared, I can't think of any good reason to put #Deprecated on these methods.
They are indeed a very convenient way of accessing location pointed to by the blue dot.
A single line
Location location = map.getMyLocation();
to retrieve my location vs the amount of setup code we need to write using the new Location API to achieve the same result speaks against having them deprecated.
From the MyLocationDemoActivity (under ANDROID_SDK/extras/google/google_play_services/samples/maps/src/com/example/mapdemo/MyLocationDemoActivity.java):
// These settings are the same as the settings for the map. They will in fact give you updates at
// the maximal rates currently possible.
private static final LocationRequest REQUEST = LocationRequest.create()
.setInterval(5000) // 5 seconds
.setFastestInterval(16) // 16ms = 60fps
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
The comment suggests that these hardcoded values are the same as in the map, but this may change in an undesirable way in future.
So after all the pros and cons are here, what could be the reason behind desision to deprecate these APIs?.
One more point. If GoogleMap uses LocationClient, but we don't have access to its results and we have to use another LocationClient and bunch of listeners, it is two LocationClients for the same task. Pure waste of resources.

Categories

Resources