Edgar
Edgar

Reputation: 179

How to use POI/Geocoding search in skobbler

I want to search a places using string in skobbler. Like waze when i search for example "universal studios usa los angeles" then search the geo points of the universal will be given to me. thanks in advance.

Upvotes: 1

Views: 624

Answers (2)

user1079425
user1079425

Reputation:

Well, I think you don't really need to complicate things and rely on Skobbler for this, you can use the Android native geocoding API. The results are pretty accurate.

Note that the following runs on the UI thread, you may want to put it on an AsyncTask or whatever.

private void geocode (String address) {
    String baseUrl          = "";
    String [] splitAddress  = address.split ("[,\\s\\-:\\?]");
    for (int i = 0; i < splitAddress.length; i++) {
        if (i != 0) {
            baseUrl += "+";
        }
        baseUrl += splitAddress [i];
    }
    if (NetUtils.isOnline (MyActivity.this)) {
        Geocoder geocoder = new Geocoder (MyActivity.this);
        try {
            ProgressView.show (MyActivity.this, true);
            List<Address> addresses = geocoder.getFromLocationName (baseUrl, 1);
            if (addresses != null && addresses.size() > 0) {
                Address addressResult = addresses.get (0);

                Log.e (MyActivity.this.class.getSimpleName () + " -- Address Found", address + " : " + addressResult.getLatitude () +  " : " + addressResult.getLongitude());

                launchRouteCalculation (addressResult.getLatitude (), addressResult.getLongitude ());
            } else {
                PopupUtils.show (MyActivity.this, null, "Could not find the destination.");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            ProgressView.dismiss ();
        }
    }

Upvotes: 0

Ando
Ando

Reputation: 11439

Right now the SDK offers 2 ways of searching:

If I understand correctly you are looking for a "one line search" component (type your query in one line and Enter) - this is something that the SDK doesn't currently expose (we are working on it and in November we should have new developments regarding this).

Upvotes: 3

Related Questions