Giter VIP home page Giter VIP logo

placepicker-sdk-sample's Introduction

Place Picker SDK

An SDK to help developers add a place picker to their app and also quickly access the Foursquare place that their user is at.

Download

compile 'com.foursquare:placepicker:0.6.1'

Demo

currentplace
pickplace
changelocation

Usage

Initialize the SDK with your consumer key and secret.

PlacePickerSdk.with(new PlacePickerSdk.Builder(this)
                .consumer(CONSUMER_KEY, CONSUMER_SECRET)
                .imageLoader(new PlacePickerSdk.ImageLoader() {
                    @Override
                    public void loadImage(Context context, ImageView v, String url) {
                        Glide.with(context)
                                .load(url)
                                .placeholder(R.drawable.category_none)
                                .dontAnimate()
                                .into(v);
                    }
                })
                .build());

If you want to get the current place of your user:

private void getClosestPlace() {
    PlacePickerSdk.get().getCurrentPlace(new PlacePickerSdk.CurrentPlaceResult() {
        @Override
        public void success(Venue venue, boolean confident) {
            Toast.makeText(MainActivity.this,"Got closest place " + venue.getName() + " Confident? " + confident, Toast.LENGTH_LONG).show();
        }

        @Override
        public void fail() {
        }
    });
}

To launch the place picker, open the intent and handle the result in onActivityResult():

private void pickPlace() {
    Intent intent = new Intent(this, PlacePicker.class);
    startActivityForResult(intent, 9001);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == PlacePicker.PLACE_PICKED_RESULT_CODE) {
        Venue place = data.getParcelableExtra(PlacePicker.EXTRA_PLACE);
        Toast.makeText(this, place.getName(), Toast.LENGTH_LONG).show();
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

placepicker-sdk-sample's People

Contributors

kylefowler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

placepicker-sdk-sample's Issues

Not able to get distance from perticular source to destination.

Hi Guys,
I have used this SDK into my project, but when I searched for the perticular place distance showing from the current location, I have used following method
private void pickPlace() {
Intent i = new Intent(this, PlacePicker.class);
startActivityForResult(i, 9001);
}
But I want to calculate distance between one of the predefined place not from my current location, is their any other method to pass source as well as destination.

Spinner

Hi! First of all very nice work! Thank you guys for this example.
I´m new on this so it maybe sounds very dumb but, can i populate a spinner with categories and pass the parameters to filter the results by categories? If yes could you give me an example? Thank´s in advance.

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.