GithubHelp home page GithubHelp logo

tanwu520 / addresspicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bilalsiddiqui/addresspicker

0.0 1.0 0.0 837 KB

A simple light weight android library to pick address from google map and places API

License: MIT License

Kotlin 100.00%

addresspicker's Introduction

AddressPicker

A simple light weight android library to pick address from google map and places API

Alt text Alt text

Usage:

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

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

Step 2. Add the dependency

dependencies {
        implementation 'com.github.BilalSiddiqui:AddressPicker:Tag'
}

Step 3. Add Google Places API key in manifest

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

Step 4. Start address picker activity.

        val intent = Intent(this@MainActivity, AddressPickerActivity::class.java)
        intent.putExtra(AddressPickerActivity.ARG_LAT_LNG,MyLatLng(42.5328966, -122.7751082))
        val pinList=ArrayList<Pin>()
        pinList.add(Pin(MyLatLng(42.329989, -122.3100),"Work"))
        pinList.add(Pin(MyLatLng(42.023123, -122.23414),"Home"))
        intent.putExtra(AddressPickerActivity.ARG_LIST_PIN,  pinList)
        intent.putExtra(AddressPickerActivity.ARG_ZOOM_LEVEL,  1.0f)
        startActivityForResult(intent,REQUEST_ADDRESS )

Step 5. Get result in onActivityResult.

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (requestCode == REQUEST_ADDRESS && resultCode == Activity.RESULT_OK) {
        val address: Address? = data?.getParcelableExtra(RESULT_ADDRESS) as Address
        selected_address.text =
            address?.featureName + ", " + address?.locality + ", " + address?.adminArea + ", " + address?.countryName

    }
} 

Features:

1- Search in PLACES API.

2- Search and select on map.

3- Set zoom level of map.

4- You can provide list of pin/marker for map to show

5- You can provide lat/lng to set initial postion of map through intent extras.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.