Description
Introduction
LocationPicker is a simple and easy to use library that can be integrated into your project.
The project is build with androidx.
All libraries and APIs used in the project are up-to-date as of now
You can get latitude,longitude and full address for selected location
Please follow below instruction to know how to use it in your project
Features
- Search any location using Google Places Library
- Pick any location from the map
- Open the picked location on Google Maps
- Search the Direction to the picked location from current location (using Google Maps)
LocationPicker alternatives and similar packages
Based on the "Maps" category.
Alternatively, view LocationPicker alternatives based on common mentions on social networks and blogs.
-
Smart Location Library
Android library project that lets you manage the location updates to be as painless as possible -
Google-Directions-Android
This project allows you to calculate the route between two locations and displays it on a map. -
Android Maps Extensions
Android Maps Extensions is a library extending capabilities of Google Maps Android API v2. -
drawroute
DrawRoute wraps Google Directions API (https://developers.google.com/maps/documentation/directions/) using RxJava for Android so developers can download, parse and draw path on the map in very fast and flexible way (For now only JSON support). -
Android-Google-Map-Polygon
the simple utility for google maps in android : http://www.tellmehow.co/add-google-map-android-extramaputils-library/ -
GLMap
Crossplatform offline vector map with MapCSS styling. Offline search and offline navigation are included.
InfluxDB - Purpose built for real-time analytics at any scale.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of LocationPicker or a related project?
README
Introduction LocationPicker is a simple and easy to use library that can be integrated into your project. The project is build with androidx. All libraries and APIs used in the project are up-to-date as of now You can get latitude,longitude and full address for selected location Please follow below instruction to know how to use it in your project
Features
- Search any location using Google Places Library
- Pick any location from the map
- Edit Location and add more Details
- Get location in a bundle with city , pincode , state etc
- Open the picked location on Google Maps
- Search the Direction to the picked location from current location (using Google Maps)
Getting Started
Gradle Integration Add it in your root build.gradle at the end of repositories: step 1:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
step 2: Add the dependency
dependencies {
implementation 'com.github.shivpujan12:LocationPicker:2.0'
}
Follow below step to use LocationPicker Library
1) Configure your app in Google API Console to get API Key and enable services.
2) Enable below services in API Console.
Google Maps Android API
Google Places API for Android
3) Declare the following things in manifest in AndroidManifest.xml file
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
inside <application>
tag add <meta-data>
as shown below
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
....
....
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/your_api_key" />
</application>
Note: Create the 'your_api_key' string resource and add your api key there
4) To use the LocationPicker in your activity add the following code:
i) Inside onCreate method intialize your api key as below:<br/>
```java
MapUtility.apiKey = getResources().getString(R.string.your_api_key);
```
<p><b>Note:</b> Create the 'your_api_key' string resource and add your api key there</p>
ii) Start Location picker request by putting below code in your view<br/>
```java
Intent i = new Intent(MainActivity.this, LocationPickerActivity.class);
startActivityForResult(i, ADDRESS_PICKER_REQUEST);
```
5) Handle your onActivityResult for getting address, latitude and longitude as:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == ADDRESS_PICKER_REQUEST) {
try {
if (data != null && data.getStringExtra(MapUtility.ADDRESS) != null) {
// String address = data.getStringExtra(MapUtility.ADDRESS);
double currentLatitude = data.getDoubleExtra(MapUtility.LATITUDE, 0.0);
double currentLongitude = data.getDoubleExtra(MapUtility.LONGITUDE, 0.0);
Bundle completeAddress =data.getBundleExtra("fullAddress");
/* data in completeAddress bundle
"fulladdress"
"city"
"state"
"postalcode"
"country"
"addressline1"
"addressline2"
*/
txtAddress.setText(new StringBuilder().append("addressline2: ").append
(completeAddress.getString("addressline2")).append("\ncity: ").append
(completeAddress.getString("city")).append("\npostalcode: ").append
(completeAddress.getString("postalcode")).append("\nstate: ").append
(completeAddress.getString("state")).toString());
txtLatLong.setText(new StringBuilder().append("Lat:").append(currentLatitude).append
(" Long:").append(currentLongitude).toString());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Extra Feature :wink: To open the LocationPicker with pre-selected location, just add extras to the Intent as below:
Intent intent = new Intent(EditorActivity.this, LocationPickerActivity.class);
intent.putExtra(MapUtility.COUNTRY_ISO_CODE, "US"); // Only show US locations
intent.putExtra(MapUtility.ADDRESS,address);
intent.putExtra(MapUtility.LATITUDE, latitude);
intent.putExtra(MapUtility.LONGITUDE, longitude);
startActivityForResult(intent, ADDRESS_PICKER_REQUEST);
Bugs and Feedback :thumbsup: :thumbsdown: For bugs, questions and discussions please use the Github Issues. If you like this library please put a star :star: to it
Credits
The library is referenced from https://github.com/Intuz-production/AddressPicker-Android
Connect with me!