Skip to content

Simple(vanilla) yet 'Do it all' place picker for your place picking needs in Android

License

Notifications You must be signed in to change notification settings

akashmi/VanillaPlacePicker

 
 

Repository files navigation

Vanilla Place Picker

Vanilla Place Picker provides a UI that displays an interactive map to get the place details and Autocomplete functionality, which displays place predictions based on user search input.

Preview

image image

Key features

  • Simple implementation for place picker either using Autocomplete, Map or both
  • Set your own custom map styles
  • Customise map pin icon
  • Set default location position
  • Use it without location permission
  • Choose to show only open businesses or all
  • Highly customise attributes

Usage

  • Dependencies

    Step 1. Add the JitPack repository to your build file

    Add it in your root build.gradle at the end of repositories:

        allprojects {
    	    repositories {
    		    ...
    		    maven { url 'https://jitpack.io' }
    	    }
        }

    Step 2. Add the dependency

    Add it in your app module build.gradle:

        dependencies {
            ...
            implementation 'com.github.Mindinventory:VanillaPlacePicker:1.0.0'
        }
  • Implementation

    Step 1. Add GOOGLE MAP API KEY to your AndroidManifest.xml:

      <application ... >
        ...
        
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/YOUR_GOOGLE_MAPS_API_KEY" />
        
      </application>

    Step 2. Add VanillaPlacePicker Builder in to your activity class:

            VanillaPlacePicker.Builder(this, KeyUtils.REQUEST_PLACE_PICKER)
                .withLocation(23.057582, 72.534458)
    
                /*
                * Configuration for AutoComplete UI
                * */
                .setRegion("IN")
                .setLanguage("en")
                .isOpenNow(true) // Returns only those places that are open for business at the time the query is sent.
                .setTintColor(R.color.colorPrimaryAmber) // Apply Tint color to Back, Clear button of AutoComplete UI
                ...
    
                /*
                * Configuration for Map UI
                * */
                .enableMap() // Enable to select place from map
                .setMapStyle(R.raw.style_json) // containing the JSON style declaration for night-mode styling
                .setMapPinDrawable(android.R.drawable.ic_menu_mylocation) // To give custom pin image for map marker
                ...
    
                .build()
          
        ...
    
        //----- override onActivityResult function to get Vanilla Place Picker result.
        override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
            super.onActivityResult(requestCode, resultCode, data)
            if (resultCode == Activity.RESULT_OK && data != null) {
                when (requestCode) {
                    REQUEST_PLACE_PICKER -> {
                        val vanillaAddress = data.getSerializableExtra(KeyUtils.SELECTED_PLACE) as VanillaAddress
                        // Do needful with your vanillaAddress
                    }
                }
            }
        }
        

LICENSE!

Vanilla Place Picker is MIT-licensed.

Let us know!

We’d be really happy if you send us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding our work.

About

Simple(vanilla) yet 'Do it all' place picker for your place picking needs in Android

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 98.5%
  • Java 1.5%