Please follow the below steps to integrate this control in your project.
- Easy & Fast to retrive location.
- You can select a location from Google Place API or User’s current location.
- Can Customize according to requirement.
To use this component in your project you need to perform below steps:
- Configure your app in Google API Console to get API Key and enable services.
- Enable below services in API Console.
Google Maps Android API
Google Places API for Android
- Permission and declaration in AndroidManifest.xml file
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Note: replace ‘’ with your google api key in manifeast.xml file.
- Start Address picker request by putting below code in your view :
Intent intent = new Intent(MainActivity.this, LocationPickerActivity.class);
startActivityForResult(intent, ADDRESS_PICKER_REQUEST);
- 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("address") != null) {
String address = data.getStringExtra("address");
double currentLatitude = data.getDoubleExtra("lat", 0.0);
double currentLongitude = data.getDoubleExtra("long", 0.0);
txtAddress.setText("Address: "+address);
txtLatLong.setText("Lat:"+currentLatitude+" Long:"+currentLongitude);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Copyright (c) 2018 INTUZ
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.