小编use*_*669的帖子

通过json(url)计算用户位置和餐厅位置之间的距离

我有latitudelongitude它是从URL(JSON)的到来.我必须计算从用户位置(需要首先确定)到特定latitudelongitude基础(来自URL)的距离,并显示它们之间的距离.

可以在附加图像上看到JSON数据:

在此输入图像描述

获取(餐馆的纬度和经度)JSON数据的URL:https://comida-95724.herokuapp.com/api/v1/restaurants/get_featured_restaurants

ListActiivty.java

 public class ListViewActivity extends Activity {
    // Log tag
    private static final String TAG = ListViewActivity.class.getSimpleName();
    // change here url of server api
    private static final String url = "https://comida-95724.herokuapp.com/api/v1/restaurants/get_featured_restaurants";

    private ProgressDialog pDialog;
    private List<Movie> movieList = new ArrayList<Movie>();
    private ListView listView;

    private CustomListAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_listview);
        listView = (ListView) findViewById(R.id.list);
        adapter = new CustomListAdapter(this, movieList);

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { …
Run Code Online (Sandbox Code Playgroud)

android json google-maps google-places-api

5
推荐指数
1
解决办法
473
查看次数

标签 统计

android ×1

google-maps ×1

google-places-api ×1

json ×1