LocationPicker 2.1 0.4 Java - A simple and easy to way to pick a location from map

Related tags

Maps LocationPicker
Overview

Android Arsenal API +16

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.

https://console.cloud.google.com/apis/dashboard

  1. Enable below services in API Console.
  Google Maps Android API
  
  Google Places API for Android
  
  1. 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

  1. To use the LocationPicker in your activity add the following code:

    i) Inside onCreate method intialize your api key as below:

          MapUtility.apiKey = getResources().getString(R.string.your_api_key);

    Note: Create the 'your_api_key' string resource and add your api key there

    ii) Start Location picker request by putting below code in your view

                  Intent i = new Intent(MainActivity.this, LocationPickerActivity.class);
                  startActivityForResult(i, ADDRESS_PICKER_REQUEST);
  2. 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 😉


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.ADDRESS,address);
      intent.putExtra(MapUtility.LATITUDE, latitude);
      intent.putExtra(MapUtility.LONGITUDE, longitude);
      startActivityForResult(intent, ADDRESS_PICKER_REQUEST);



Bugs and Feedback 👍 👎

For bugs, questions and discussions please use the Github Issues. If you like this library please put a star to it

Credits

> The library is referenced from https://github.com/Intuz-production/AddressPicker-Android

Connect with me!

TwitterLink
LinkedInLink

Comments
  • A new option added to restrict search based on Country

    A new option added to restrict search based on Country

    A new option added to restrict search based on Country It can be set by adding value to Intent through "COUNTRY_ISO_CODE" flag. Contributors.md file added.

    opened by asad175 2
  • The maps dont work on Android Pie

    The maps dont work on Android Pie

    The maps dont show it in Android 29 (Pie), and the location search dont load the request, I have my own key of API Google places and maps. Everything else its ok. I will be thankful so much if you help me. Sorry for the bad english, regards from Mexico.

    opened by luiiss997 2
  • Hello i made many changes to your library

    Hello i made many changes to your library

    Java edits

    • changed the way the address is shared to main_activity. now it sends in a bundle named as "fullAddress" via intent

    UI changes

    • Added Bottom Layout to view and edit address using edit text
    • Map Zoom is only changed when User pinch in or out
    • Removed zoom out on click
    • New Marker Image
    • A little tweak to the search bar

    Thank you for your time : )

    opened by RohanArora13 2
  • Location searching issue

    Location searching issue

    Hi, While trying to search the location, it got automatically closed. I am using places api. It was working fine before. This issue happens within two three days ago. Can you help me to sort it out. Any help should be highly appreciated.

    Thanks & Regards, Cijo K Paul

    Screenshot_20200808-102754872

    opened by CijoKPaul 1
  • Flat No/ Floor / Landmark

    Flat No/ Floor / Landmark

    On location select activity we have field for Flat No / Floor / Landmark

    How to get the above field value entered by user, "addressline1" is null

    opened by rohitkzoom 0
Owner
Shivpujan yadav
Shivpujan yadav
This is a repo for implementing Map pan or drag (up, down, right ,left) to load more places on the Google Map for Android

Challenge Display restaurants around the user’s current location on a map ○ Use the FourSquare Search API to query for restaurants: https://developer.

Mahmoud Ramadan 7 Jul 30, 2022
My Maps displays a list of maps, each of which show user-defined markers with a title, description, and location. The user can also create a new map. The user can save maps and load them in from previous usages of the app.

My Maps Bryant Jimenez My Maps displays a list of maps, each of which show user-defined markers with a title, description, and location. The user can

null 0 Nov 1, 2021
malik dawar 87 Sep 18, 2022
This project allows you to calculate the route between two locations and displays it on a map.

Google-Directions-Android This project allows you to calculate the direction between two locations and display the route on a Google Map using the Goo

Joel Dean 970 Dec 15, 2022
typedmap is an implementation of heterogeneous type-safe map pattern in Kotlin

Typedmap typedmap is an implementation of heterogeneous type-safe map pattern in Kotlin. It is a data structure similar to a regular map, but with two

Ryszard Wiśniewski 34 Nov 7, 2022
Slime loader is a map loader & saver for the file format Slime as specified here implemented in Minestom.

??️ SlimeLoader Slime loader is a map loader & saver for the file format Slime as specified here implemented in Minestom. Features: World loading Bloc

null 25 Oct 2, 2022
Self-hosted map of visited places (with a very fancy stack underneath)

Tripmap Self-hosted map of visited places (with a very fancy stack underneath) Features Sharing custom map-view with pins in locations marked by user.

Igor Kurek 2 Feb 6, 2022
Positional is a location information app for Android with Compass, Clock, Level, Sun and Moon and many other features.

Positional is a location based app that utilizes the device's GPS and fetches various details of the current latitude and longitude data like Altitude, Speed, Address and similar other information and show it in easily understandable format to the user. Alongside this main functionality of being a location app, Positional also provides a separate panel for Compass and Clock, and they serve their own purpose as their name suggests.

Hamza Rizwan 85 Dec 28, 2022
An android app that uses Google Maps API and SDK to track a user's location and calculate the total distance travelled

Bike Rush is an android app that uses Google Maps API and SDK to track a user's location and calculate the total distance travelled by him or her along with time and average speed.

Ishant Chauhan 21 Nov 14, 2022
Android library project that lets you manage the location updates to be as painless as possible

Smart Location Library Android library project that intends to simplify the usage of location providers and activity recognition with a nice fluid API

Nacho Lopez 1.6k Dec 29, 2022
Android library that allows you to determine your location in a few of lines

locsimple Android library that allows you to determine your location in some lines! Benefits: automatic processing of permissions processing of enabli

Dmitry 7 Aug 31, 2022
App usage tracker which maps your app usage to geo location.

Guilt Guilt is an inspiration from Meta (pun intended), it tracks the apps usage and maps it with geo location data where the app was last used. The a

null 6 Dec 28, 2022
🍃 Organic Maps is an Android & iOS offline maps app for travelers, tourists, hikers, and cyclists based on top of crowd-sourced OpenStreetMap data and curated with love by MapsWithMe founders.

?? Organic Maps is an Android & iOS offline maps app for travelers, tourists, hikers, and cyclists based on top of crowd-sourced OpenStreetMap data and curated with love by MapsWithMe founders. No ads, no tracking, no data collection, no crapware.

Organic Maps 4.3k Dec 31, 2022
Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.

Mapbox 247 Dec 27, 2022
Google Maps Api test using marker rotation and routes.

Google Maps Api test using marker rotation and routes. Features ✔️ Kotlin ✔️ DI: Hilt ✔️ Retrofit ✔️ Gson ✔️ View binding ✔️ Coroutines ✔️ AndroidX ✔️

Carlos Adan 39 Jul 15, 2022
Dual Camera, IMU, and GPS data recorder for Android

Dual Camera, IMU, and GPS data recorder for Android

AUT 3D Vision 17 Oct 24, 2022
The app has got fullscreen Turkey map via Huawei Map. App selects random province and shows it borders on the map than user will try to guess the provinces name.

Il Bil App Introduction I will introduce you to how to implement Account Kit, Map Kit, Game Service. About the game: The app has got fullscreen Turkey

Gökhan YILMAZ 4 Aug 2, 2022
Tree View; Mind map; Think map; tree map

A custom tree view for Android, designed for easy drawing some tree nodes (e.g. thind mind and tree nodes). Includes smoothly zoom, move, limit and center fix animation support, and allows easy extension so you can add your own child node's customs view and touch event detection.

怪兽N 304 Jan 3, 2023
Google map location tracker uploading current to realtime database and displaying location information from firebase realtime.

WEEK-8-SQ009-ANDROID LOCATION - GROUP WORK (2) Problem Description Track your partner(s). Implementation 1: You are to build a map application to show

null 0 Mar 16, 2022
Durim Aliu 0 Feb 1, 2022