Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mindinventory/vanilla-place-picker

Simple(vanilla) yet 'Do it all' place picker for your place picking needs in Android
https://github.com/mindinventory/vanilla-place-picker

android autocomplete easy-to-use kotlin kotlin-android picker placepicker vanilla

Last synced: 3 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# Vanilla Place Picker
[![](https://jitpack.io/v/Mindinventory/VanillaPlacePicker.svg)](https://jitpack.io/#Mindinventory/VanillaPlacePicker) ![](https://img.shields.io/github/license/mindinventory/VanillaPlacePicker)

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
![image](/media/vanillaplacepicker-autocomplete.gif) ![image](/media/vanillaplacepicker-map.gif)

## Key features
* Android 13 support
* 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 in your project build.gradle:**
```bash
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
**or**
**If Android studio version is Arctic Fox or higher then add it in your settings.gradle**

```bash
dependencyResolutionManagement {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
- **Step 2. Add the dependency in your app module build.gradle file**
```bash
dependencies {
...
implementation 'com.github.Mindinventory:VanillaPlacePicker:X.X.X'
}
```

### Implementation
- **Step 1. Add Google MAP API KEY in your local.properties file with the same variable name as defined below (google.maps_api_key)**
```bash
google.maps_api_key=PLACE YOUR API KEY HERE
```

- **Step 2. To get Google MAP Api key from local.properties file, write below defined code in your app module build.gradle file**
```bash
android {
...
defaultConfig {
...
#Access Google MAP Api Key from local.properties file
def properties = new Properties()
file("../local.properties").withInputStream { properties.load(it)
#Share the key with your `AndroidManifest.xml`
manifestPlaceholders = [ googleMapsApiKey:"${properties.getProperty('google.maps_api_key')}"]
}
```
- **Step 3. Add below defined meta-data code to your AndroidManifest.xml:**

```bash

...




```
- **Step 4. Add VanillaPlacePicker Builder in to your activity class:**
```bash

#startActivityForResult is deprecated so better to use registerForActivityResult
var placePickerResultLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK && result.data != null) {
val vanillaAddress = VanillaPlacePicker.getPlaceResult(result.data)
}
}

#Launch caller with Intent
val intent = VanillaPlacePicker.Builder(this)
.with(PickerType.MAP_WITH_AUTO_COMPLETE) // Select Picker type to enable autocompelte, map or both
.withLocation(23.057582, 72.534458)
.setPickerLanguage(PickerLanguage.HINDI) // Apply language to picker
.setLocationRestriction(LatLng(23.0558088,72.5325067), LatLng(23.0587592,72.5357321)) // Restrict location bounds in map and autocomplete
.setCountry("IN") // Only for Autocomplete
.enableShowMapAfterSearchResult(true) // To show the map after selecting the place from place picker only for PickerType.MAP_WITH_AUTO_C
/*
* Configuration for Map UI
*/
.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()

placePickerResultLauncher.launch(intent)

```

## Requirements

* minSdkVersion >= 21
* Androidx

# LICENSE!

Vanilla Place Picker is [MIT-licensed](/LICENSE).

# 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.