Show current location and nearby places and route between two places using Google Maps API on Android

I need to develop an application using Google Maps in Android to find my current location and find the nearest place.

(For example: Near the police station from my current location .)

It should accept my current location, and the output should be displayed in the nearest place.

Can someone help me give some suggestion, links, tutorial to do this?

+49
android google-maps google-places-api
Dec 08 2018-11-12T00:
source share
4 answers
  • First go through this tutorial to familiarize yourself with Android Google Maps and this is for API 2 .

  • To get the current location of the device, see this answer or this other answer and API 2

  • You can then find places near your location using the Google Place API and for using Place Api see this blog .

  • After getting tags near a location, use this source code blog to show markers on a map with an overlay balloon with API 2.

  • You also have an excellent choice for the route between two points on the map; see Link1 and Link2 here in these links and an excellent answer .

After completing these steps, you can easily execute your application. The only condition: you will need to read it and understand, because, like magic, it will not be a complete click.

+147
Dec 08 2018-11-12T00:
source share

There are still many answers that are great pointers to APIs and tutorials. One thing I would like to add is that I figure out how much the markers from my location use something like:

 float distance = (float) loc.distanceTo(loc2); 

We hope this helps clarify the details of your problem. It returns a rough estimate of the distance (in meters) between points and is useful for getting rid of a POI that might be too far - well, to declare your map?

+13
Dec 08 '11 at 12:53 on
source share

Here you can use google map Retrieving user location .

After getting your location (longitude and latitude) you can use google place api

This code will help you easily get your location, but not the best way.

 locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); String bestProvider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(bestProvider); 
+6
Dec 08 2018-11-12T00:
source share

You have two options for displaying a map.

  • Use the Mapping Library for Android to display the map.
  • Use Maps API V3 in web view

To display local POIs around Lat, Long use Places API

+5
Dec 08 2018-11-11T00:
source share



All Articles