1 package com.netease.nimlib.sdk.msg.attachment;
5 import org.json.JSONObject;
12 private double latitude;
13 private double longitude;
14 private String address;
36 this.latitude = latitude;
52 this.longitude = longitude;
68 this.address = address;
71 private static final String KEY_LATITUDE =
"lat";
72 private static final String KEY_LONGITUDE =
"lng";
73 private static final String KEY_DESC =
"title";
75 private void fromJson(String attach) {
76 JSONObject json = JSONHelper.parse(attach);
77 latitude = JSONHelper.getDouble(json, KEY_LATITUDE);
78 longitude = JSONHelper.getDouble(json, KEY_LONGITUDE);
79 address = JSONHelper.getString(json, KEY_DESC);
84 JSONObject
object =
new JSONObject();
86 object.put(KEY_LATITUDE, latitude);
87 object.put(KEY_LONGITUDE, longitude);
88 object.put(KEY_DESC, address);
89 }
catch (Exception e) {
93 return object.toString();
String getAddress()
获取地理位置描述信息
void setLongitude(double longitude)
设置经度
double getLongitude()
获取经度
void setAddress(String address)
设置地理位置描述信息
LocationAttachment(String attach)
String toJson(boolean send)
将消息附件序列化为字符串,存储到消息数据库或发送到服务器。
void setLatitude(double latitude)
设置纬度