m將不同的用戶latLng作爲json對象,並使用該用戶名在sqlite中存儲和更新它,現在我想要檢索用戶的lacations並將這些用戶顯示爲地圖..和更新自己的位置作爲消息AF到達用戶...該怎麼辦如何在sqlite中顯示地圖中的多個標記
這是我的代碼
JSONObject jsnobject = new JSONObject(Message);
JSONObject msg = jsnobject.getJSONObject("msg");
JSONObject header = msg.getJSONObject("Header");
clientID=header.getString("from");
JSONObject location = header.getJSONObject("Location");
LAT = location.getString("Lat");
LNG = location.getString("Long");
SPEED = location.getString("Speed");
} catch (JSONException e) {
e.printStackTrace();
}
// for(int i =0 ;i<abc;i++){
List<String> a= db.getID();
if(a.contains(clientID)){
db.update(clientID, LAT, LNG, SPEED);
}else{
db.insert(clientID, LAT, LNG, SPEED);
}
這是怎麼中號放置標記
List<String> a= db.getID();
for(int i=0;i<a.size();i++){
String id=a.get(i);
List<String> latllng= db.getLatLng(id);
latllng.toString();
String[] Latlng=latllng.toString().replace("[", "").replace("]", "").split(",");
double latitude = Double.parseDouble(Latlng[0]);
double longitude = Double.parseDouble(Latlng[1]);
googleMap.clear();
if (marker == null)
pos=new LatLng(latitude,longitude);
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
pos, 17));
marker = googleMap.addMarker(new MarkerOptions()
.position(pos));
marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.my_marker));
marker.setTitle(id);
pos = new LatLng(latitude, longitude);
animateMarker(marker, pos, hideMarker);
}
請告訴我如何存儲在sqlite的 – shubham