这是一个 ListView,我可以显示可用的城市和地点。我想显示从当前点到所列地点的距离。
例如:
+++++++++++++++++++++++++
Name :Hotel Hilton
Category :hotel
distance:1km
+++++++++++++++++++++++++
如何计算并显示列表中的每个距离值?
ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();
JSONArray jsonArray = new JSONArray(response);
if (jsonArray != null) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject object = (JSONObject) jsonArray.get(i);
HashMap<String, String> map = new HashMap<String, String>();
map.put(TAG_Name, object.getString("name"));
map.put(TAG_Category, object.getString("category"));
map.put(TAG_Lat, object.getString("lat"));
map.put(TAG_Lng, object.getString("lng"));
contactList.add(map);
}
}
ListAdapter adapter = new SimpleAdapter(this, contactList,
R.layout.menu_list_row, new String[] { TAG_Name,
TAG_Category }, new int[] { R.id.LR_Name,
R.id.LR_date });
list.setAdapter(adapter);
}
当前位置从 GPS 识别并存储为 lat,lng。