Place Search Dialog

A place autocomplete search dialog which uses Google's places API for finding results.

The dialog searches for locations from all around the world. To customize it, set the new location bounds using .setLatLngBounds(BOUNDS)

How to use

Setup

PlaceSearchDialog requires Places API key by Google. You can get it from here.

Use the dialog as it is

 PlaceSearchDialog placeSearchDialog = new PlaceSearchDialog.Builder(this)
                .setLocationNameListener(new PlaceSearchDialog.LocationNameListener() {
                    @Override
                    public void locationName(String locationName) {
                        //set textview or edittext
                    }
                })
                .build();
placeSearchDialog.show();

or Customize it accordingly

 PlaceSearchDialog placeSearchDialog = new PlaceSearchDialog.Builder(this)
                .setHeaderImage(R.drawable.dialog_header)
                .setHintText("Enter location name")
                .setHintTextColor(R.color.light_gray)
                .setNegativeText("CANCEL")
                .setNegativeTextColor(R.color.gray)
                .setPositiveText("SUBMIT")
                .setPositiveTextColor(R.color.red)
                .setLatLngBounds(BOUNDS)
                .setLocationNameListener(new PlaceSearchDialog.LocationNameListener() {
                    @Override
                    public void locationName(String locationName) {
                        //set textview or edittext
                    }
                })
                .build();
placeSearchDialog.show();

Add this in your applications AndroidManifest.xml

<meta-data android:name="com.google.android.geo.API_KEY"
            android:value="YOUR_API_KEY" />

Installation

Gradle

Just use it as a dependency in your app's build.gradle file

dependencies {
    compile 'com.codemybrainsout.placesearchdialog:placesearch:1.0.1'
}

Maven

Ensure you have android-maven-plugin version that support aar archives and add following dependency:

<dependency>
  <groupId>com.codemybrainsout.placesearchdialog</groupId>
  <artifactId>placesearch</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

GitHub