Vanilla Place Picker - Place Picking Needs for Android

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.

Developers often come across a requirement of adding precise location. So, a place picker which is easy to implement, less time consuming, and simple enough for users to use it is always in demand and here we have a Vanilla Place Picker which developer can add it in quick simple steps.

Preview

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
  • Multi languages support.
  • RTL layout support.

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:0.0.7'
        }
  • 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:

    val intent = VanillaPlacePicker.Builder(this)
                .withLocation(23.057582, 72.534458)
                .setPickerLanguage(PickerLanguage.HINDI) // Apply language to picker
                .setTintColor(R.color.colorPrimaryAmber) // Apply Tint color to Back, Clear button of AutoComplete UI
                /*
                 * 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.
                ...
    
                /*
                 * Configuration for Map UI
                 */
                .with(PickerType.MAP_WITH_AUTO_COMPLETE) // Select Picker type to enable autocompelte, map or both
                .setMapType(MapType.SATELLITE) // Choose map type (Only applicable for map screen) 
                .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()
    
            startActivityForResult(intent, REQUEST_PLACE_PICKER)
    
        ...
    
        //----- 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
                    }
                }
            }
        }

Requirements

  • minSdkVersion >= 17
  • Androidx

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 sales@mindinventory.com And do let us know if you have any questions or suggestion regarding our work.

我来评几句
登录后评论

已发表评论数()

相关站点

+订阅
热门文章