如何在skobbler中使用POI /地理编码搜索

时间:2014-09-29 03:14:22

标签: android map skmaps

我想在skobbler中使用字符串搜索地点。就像我在寻找例如"环球影城美国洛杉矶"然后搜索普遍的地理点将给我。提前致谢。

2 个答案:

答案 0 :(得分:3)

目前,SDK提供了两种搜索方式:

如果我理解正确,你正在寻找"一行搜索"组件(在一行中键入您的查询并输入) - 这是SDK目前没有公开的内容(我们正在研究它,并且在11月我们应该有关于此的新发展)。

答案 1 :(得分:0)

嗯,我认为你真的不需要复杂化并依赖于Skobbler,你可以使用Android原生地理编码API。结果非常准确。

请注意,以下在UI线程上运行,您可能希望将其放在AsyncTask或其他任何内容上。

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 ();
        }
    }