|
|
@ -27,6 +27,7 @@ import com.orhanobut.logger.Logger;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.bmob.imdemo.R;
|
|
|
|
import cn.bmob.imdemo.R;
|
|
|
@ -34,40 +35,45 @@ import cn.bmob.imdemo.adapter.ChatAdapter;
|
|
|
|
import cn.bmob.imdemo.base.ParentWithNaviActivity;
|
|
|
|
import cn.bmob.imdemo.base.ParentWithNaviActivity;
|
|
|
|
import cn.bmob.imdemo.util.Utils;
|
|
|
|
import cn.bmob.imdemo.util.Utils;
|
|
|
|
import cn.bmob.imdemo.bean.FindUOverlayManager;
|
|
|
|
import cn.bmob.imdemo.bean.FindUOverlayManager;
|
|
|
|
|
|
|
|
import cn.bmob.newim.BmobIM;
|
|
|
|
import cn.bmob.newim.bean.BmobIMConversation;
|
|
|
|
import cn.bmob.newim.bean.BmobIMConversation;
|
|
|
|
import cn.bmob.newim.bean.BmobIMLocationMessage;
|
|
|
|
import cn.bmob.newim.bean.BmobIMLocationMessage;
|
|
|
|
import cn.bmob.newim.bean.BmobIMMessage;
|
|
|
|
import cn.bmob.newim.bean.BmobIMMessage;
|
|
|
|
import cn.bmob.newim.core.BmobIMClient;
|
|
|
|
import cn.bmob.newim.core.BmobIMClient;
|
|
|
|
|
|
|
|
import cn.bmob.newim.event.MessageEvent;
|
|
|
|
|
|
|
|
import cn.bmob.newim.listener.MessageListHandler;
|
|
|
|
import cn.bmob.newim.listener.MessageSendListener;
|
|
|
|
import cn.bmob.newim.listener.MessageSendListener;
|
|
|
|
|
|
|
|
import cn.bmob.newim.listener.ObseverListener;
|
|
|
|
import cn.bmob.v3.exception.BmobException;
|
|
|
|
import cn.bmob.v3.exception.BmobException;
|
|
|
|
|
|
|
|
|
|
|
|
public class LocActivity extends ParentWithNaviActivity{
|
|
|
|
public class LocActivity extends ParentWithNaviActivity implements ObseverListener,MessageListHandler {
|
|
|
|
MapView mMapView = null;
|
|
|
|
public MapView mMapView = null;
|
|
|
|
BaiduMap mBaiduMap = null;
|
|
|
|
public BaiduMap mBaiduMap = null;
|
|
|
|
public LocationClient mLocationClient = null;
|
|
|
|
public LocationClient mLocationClient = null;
|
|
|
|
public BDLocationListener myListener = new MyLocationListener();
|
|
|
|
public BDLocationListener myListener = new MyLocationListener();
|
|
|
|
|
|
|
|
|
|
|
|
private MyLocationData mylocdata = null;
|
|
|
|
public LatLng my_loc = new LatLng(28.233982,113.003927);
|
|
|
|
private MyLocationData friendlocdata = null;
|
|
|
|
public LatLng friend_loc = new LatLng(28.233982,113.003927);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private LinkedList<LocationEntity> locationList = new LinkedList<LocationEntity>(); // 存放历史定位结果的链表,最大存放当前结果的前5次定位结果
|
|
|
|
private LinkedList<LocationEntity> locationList = new LinkedList<LocationEntity>(); // 存放历史定位结果的链表,最大存放当前结果的前5次定位结果
|
|
|
|
int exe_count = 0;
|
|
|
|
int exe_count = 0;
|
|
|
|
BmobIMConversation c;
|
|
|
|
BmobIMConversation c;
|
|
|
|
ChatAdapter adapter;
|
|
|
|
//ChatAdapter adapter;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
|
|
|
|
//初始化百度地图的定位接口
|
|
|
|
//初始化百度地图的定位接口
|
|
|
|
mLocationClient = new LocationClient( getApplicationContext());
|
|
|
|
mLocationClient = new LocationClient(getApplicationContext());
|
|
|
|
SDKInitializer.initialize(getApplicationContext());
|
|
|
|
SDKInitializer.initialize(getApplicationContext());
|
|
|
|
mLocationClient.registerLocationListener( myListener );
|
|
|
|
mLocationClient.registerLocationListener(myListener);
|
|
|
|
|
|
|
|
|
|
|
|
setContentView(R.layout.activity_loc);
|
|
|
|
setContentView(R.layout.activity_loc);
|
|
|
|
c= BmobIMConversation.obtain(BmobIMClient.getInstance(), (BmobIMConversation) getBundle().getSerializable("c"));
|
|
|
|
c = BmobIMConversation.obtain(BmobIMClient.getInstance(), (BmobIMConversation) getBundle().getSerializable("c"));
|
|
|
|
adapter = new ChatAdapter(this,c);
|
|
|
|
BmobIM.getInstance().addMessageListHandler(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//adapter = new ChatAdapter(this, c);
|
|
|
|
initNaviView();
|
|
|
|
initNaviView();
|
|
|
|
initLocation();
|
|
|
|
initLocation();
|
|
|
|
mMapView = (MapView) findViewById(R.id.bmapView);
|
|
|
|
mMapView = (MapView) findViewById(R.id.bmapView);
|
|
|
@ -75,55 +81,8 @@ public class LocActivity extends ParentWithNaviActivity{
|
|
|
|
mBaiduMap = mMapView.getMap();
|
|
|
|
mBaiduMap = mMapView.getMap();
|
|
|
|
mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
|
|
|
|
mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
|
|
|
|
|
|
|
|
|
|
|
|
// 开启定位图层
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mLocationClient.start();
|
|
|
|
mLocationClient.start();
|
|
|
|
|
|
|
|
|
|
|
|
Logger.i("before \n");
|
|
|
|
|
|
|
|
//mLocationClient.requestLocation();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.i("after \n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//mBaiduMap.clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//mLocationClient.requestLocation();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//send_recv_real_time();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void send_recv_real_time() {
|
|
|
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int times = 1;
|
|
|
|
|
|
|
|
int maxtime = 1000000;
|
|
|
|
|
|
|
|
while( times < maxtime ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* BmobIMLocationMessage location =new BmobIMLocationMessage("广州番禺区",23.5,112.0);
|
|
|
|
|
|
|
|
Map<String,Object> map =new HashMap<>();
|
|
|
|
|
|
|
|
map.put("from", "百度地图");
|
|
|
|
|
|
|
|
location.setExtraMap(map);
|
|
|
|
|
|
|
|
c.sendMessage(location, listener);
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Thread.sleep(500);
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -141,12 +100,12 @@ public class LocActivity extends ParentWithNaviActivity{
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onStart(BmobIMMessage msg) {
|
|
|
|
public void onStart(BmobIMMessage msg) {
|
|
|
|
super.onStart(msg);
|
|
|
|
super.onStart(msg);
|
|
|
|
adapter.addMessage(msg);
|
|
|
|
//adapter.addMessage(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void done(BmobIMMessage msg, BmobException e) {
|
|
|
|
public void done(BmobIMMessage msg, BmobException e) {
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
//adapter.notifyDataSetChanged();
|
|
|
|
if (e != null) {
|
|
|
|
if (e != null) {
|
|
|
|
toast(e.getMessage());
|
|
|
|
toast(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -191,15 +150,14 @@ public class LocActivity extends ParentWithNaviActivity{
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected String title() {
|
|
|
|
protected String title() {
|
|
|
|
return "find ";// + c.getConversationTitle();
|
|
|
|
return "寻找 " + c.getConversationTitle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void initLocation(){
|
|
|
|
private void initLocation(){
|
|
|
|
LocationClientOption option = new LocationClientOption();
|
|
|
|
LocationClientOption option = new LocationClientOption();
|
|
|
|
option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy
|
|
|
|
option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
|
|
|
|
);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
|
|
|
|
|
|
|
|
option.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系
|
|
|
|
option.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系
|
|
|
|
int span=1000;
|
|
|
|
int span=4000;
|
|
|
|
option.setScanSpan(span);//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
|
|
|
|
option.setScanSpan(span);//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
|
|
|
|
option.setIsNeedAddress(true);//可选,设置是否需要地址信息,默认不需要
|
|
|
|
option.setIsNeedAddress(true);//可选,设置是否需要地址信息,默认不需要
|
|
|
|
option.setOpenGps(true);//可选,默认false,设置是否使用gps
|
|
|
|
option.setOpenGps(true);//可选,默认false,设置是否使用gps
|
|
|
@ -216,30 +174,7 @@ public class LocActivity extends ParentWithNaviActivity{
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onReceiveLocation(BDLocation location) {
|
|
|
|
public void onReceiveLocation(BDLocation location) {
|
|
|
|
/*StringBuffer sb = new StringBuffer(256);
|
|
|
|
|
|
|
|
sb.append("time : ");
|
|
|
|
|
|
|
|
sb.append(location.getTime());
|
|
|
|
|
|
|
|
sb.append("\nerror code : ");
|
|
|
|
|
|
|
|
sb.append(location.getLocType());
|
|
|
|
|
|
|
|
sb.append("\nlatitude : ");
|
|
|
|
|
|
|
|
sb.append(location.getLatitude());
|
|
|
|
|
|
|
|
sb.append("\nlontitude : ");
|
|
|
|
|
|
|
|
sb.append(location.getLongitude());
|
|
|
|
|
|
|
|
sb.append("\nradius : ");
|
|
|
|
|
|
|
|
sb.append(location.getRadius());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sb.append("\nlocationdescribe : ");
|
|
|
|
|
|
|
|
sb.append(location.getLocationDescribe());// 位置语义化信息
|
|
|
|
|
|
|
|
List<Poi> list = location.getPoiList();// POI数据
|
|
|
|
|
|
|
|
if (list != null) {
|
|
|
|
|
|
|
|
sb.append("\npoilist size = : ");
|
|
|
|
|
|
|
|
sb.append(list.size());
|
|
|
|
|
|
|
|
for (Poi p : list) {
|
|
|
|
|
|
|
|
sb.append("\npoi= : ");
|
|
|
|
|
|
|
|
sb.append(p.getId() + " " + p.getName() + " " + p.getRank());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Logger.i(sb.toString());*/
|
|
|
|
|
|
|
|
exe_count = exe_count + 1;
|
|
|
|
exe_count = exe_count + 1;
|
|
|
|
if (location != null && (location.getLocType() == 161 || location.getLocType() == 66)) {
|
|
|
|
if (location != null && (location.getLocType() == 161 || location.getLocType() == 66)) {
|
|
|
|
Message locMsg = locHander.obtainMessage();
|
|
|
|
Message locMsg = locHander.obtainMessage();
|
|
|
@ -257,22 +192,7 @@ public class LocActivity extends ParentWithNaviActivity{
|
|
|
|
sb.append("\n");
|
|
|
|
sb.append("\n");
|
|
|
|
Logger.i( sb.toString() );
|
|
|
|
Logger.i( sb.toString() );
|
|
|
|
mBaiduMap.setMyLocationEnabled(true);
|
|
|
|
mBaiduMap.setMyLocationEnabled(true);
|
|
|
|
/*
|
|
|
|
|
|
|
|
// 构造定位数据
|
|
|
|
|
|
|
|
MyLocationData locData = new MyLocationData.Builder()
|
|
|
|
|
|
|
|
.accuracy(location.getRadius())
|
|
|
|
|
|
|
|
// 此处设置开发者获取到的方向信息,顺时针0-360
|
|
|
|
|
|
|
|
.direction(100).latitude(location.getLatitude())
|
|
|
|
|
|
|
|
.longitude(location.getLongitude()).build();
|
|
|
|
|
|
|
|
// 设置定位数据
|
|
|
|
|
|
|
|
mBaiduMap.setMyLocationData(locData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置定位图层的配置(定位模式,是否允许方向信息,用户自定义定位图标)
|
|
|
|
|
|
|
|
BitmapDescriptor mCurrentMarker = BitmapDescriptorFactory
|
|
|
|
|
|
|
|
.fromResource(R.drawable.chat_voice_bg);
|
|
|
|
|
|
|
|
MyLocationConfiguration config = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, mCurrentMarker);
|
|
|
|
|
|
|
|
mBaiduMap.setMyLocationConfigeration(config);
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***
|
|
|
|
/***
|
|
|
@ -337,52 +257,23 @@ public class LocActivity extends ParentWithNaviActivity{
|
|
|
|
BDLocation location = msg.getData().getParcelable("loc");
|
|
|
|
BDLocation location = msg.getData().getParcelable("loc");
|
|
|
|
int iscal = msg.getData().getInt("iscalculate");
|
|
|
|
int iscal = msg.getData().getInt("iscalculate");
|
|
|
|
if (location != null) {
|
|
|
|
if (location != null) {
|
|
|
|
LatLng point = new LatLng(location.getLatitude(), location.getLongitude());
|
|
|
|
|
|
|
|
// 构建Marker图标
|
|
|
|
my_loc = new LatLng(location.getLatitude(), location.getLongitude());
|
|
|
|
BitmapDescriptor bitmap = null;
|
|
|
|
|
|
|
|
if (iscal == 0) {
|
|
|
|
refresh_map();
|
|
|
|
bitmap = BitmapDescriptorFactory.fromResource(R.drawable.chat_voice_bg_press); // 非推算结果
|
|
|
|
|
|
|
|
} else {
|
|
|
|
BmobIMLocationMessage loc_msg =new BmobIMLocationMessage("myloc",location.getLatitude(),location.getLongitude());
|
|
|
|
bitmap = BitmapDescriptorFactory.fromResource(R.drawable.chat_voice_bg); // 推算结果
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 构建MarkerOption,用于在地图上添加Marker
|
|
|
|
|
|
|
|
OverlayOptions option1 = new MarkerOptions().position(point).icon(bitmap);
|
|
|
|
|
|
|
|
LatLng point2 = new LatLng(location.getLatitude() + 0.1, location.getLongitude() + 0.1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OverlayOptions option2 = new MarkerOptions().position(point2).icon(bitmap);
|
|
|
|
|
|
|
|
LatLng point3 = new LatLng(location.getLatitude() - 0.05, location.getLongitude() - 0.05);
|
|
|
|
|
|
|
|
LatLng point4 = new LatLng(location.getLatitude() + 0.15, location.getLongitude() + 0.15);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OverlayOptions option3 = new MarkerOptions().position(point3);
|
|
|
|
|
|
|
|
OverlayOptions option4 = new MarkerOptions().position(point4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 在地图上添加Marker(多个),并显示
|
|
|
|
|
|
|
|
FindUOverlayManager overlayManager = new FindUOverlayManager(mBaiduMap);
|
|
|
|
|
|
|
|
ArrayList<OverlayOptions> aslist = new ArrayList<OverlayOptions>();
|
|
|
|
|
|
|
|
aslist.add(option1);
|
|
|
|
|
|
|
|
aslist.add(option2);
|
|
|
|
|
|
|
|
//aslist.add(option3);
|
|
|
|
|
|
|
|
//aslist.add(option4);
|
|
|
|
|
|
|
|
overlayManager.setData(aslist);
|
|
|
|
|
|
|
|
mBaiduMap.setOnMarkerClickListener(overlayManager);
|
|
|
|
|
|
|
|
overlayManager.addToMap();
|
|
|
|
|
|
|
|
if( exe_count < 3)
|
|
|
|
|
|
|
|
overlayManager.zoomToSpan();
|
|
|
|
|
|
|
|
mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng( new LatLng ( (point.latitude + point2.latitude )/ 2,(point.longitude + point2.longitude)/2)) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BmobIMLocationMessage loc_msg =new BmobIMLocationMessage("myloc",location.getLatitude(),location.getAltitude());
|
|
|
|
|
|
|
|
c.sendMessage(loc_msg, new MessageSendListener() {
|
|
|
|
c.sendMessage(loc_msg, new MessageSendListener() {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onStart(BmobIMMessage msg) {
|
|
|
|
public void onStart(BmobIMMessage msg) {
|
|
|
|
adapter.addMessage(msg);
|
|
|
|
//adapter.addMessage(msg);
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
//adapter.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void done(BmobIMMessage msg, BmobException e) {
|
|
|
|
public void done(BmobIMMessage msg, BmobException e) {
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
// adapter.notifyDataSetChanged();
|
|
|
|
if (e != null) {
|
|
|
|
if (e != null) {
|
|
|
|
toast(e.getMessage());
|
|
|
|
toast(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -395,7 +286,70 @@ public class LocActivity extends ParentWithNaviActivity{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void refresh_map() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer sb = new StringBuffer(256);
|
|
|
|
|
|
|
|
sb.append("my loc :");
|
|
|
|
|
|
|
|
sb.append(my_loc.latitude );
|
|
|
|
|
|
|
|
sb.append(" , ");
|
|
|
|
|
|
|
|
sb.append(my_loc.longitude);
|
|
|
|
|
|
|
|
sb.append(" friend loc :");
|
|
|
|
|
|
|
|
sb.append(friend_loc.latitude );
|
|
|
|
|
|
|
|
sb.append(" , ");
|
|
|
|
|
|
|
|
sb.append(friend_loc.longitude);
|
|
|
|
|
|
|
|
Logger.i( sb + " end");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LatLng point1 = my_loc;
|
|
|
|
|
|
|
|
LatLng point2 = friend_loc;
|
|
|
|
|
|
|
|
// 构建Marker图标
|
|
|
|
|
|
|
|
BitmapDescriptor bitmap = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bitmap = BitmapDescriptorFactory.fromResource(R.drawable.chat_voice_bg_press); // 非推算结果
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 构建MarkerOption,用于在地图上添加Marker
|
|
|
|
|
|
|
|
OverlayOptions option1 = new MarkerOptions().position(point1).icon(bitmap);
|
|
|
|
|
|
|
|
OverlayOptions option2 = new MarkerOptions().position(point2).icon(bitmap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 在地图上添加Marker(多个),并显示
|
|
|
|
|
|
|
|
FindUOverlayManager overlayManager = new FindUOverlayManager(mBaiduMap);
|
|
|
|
|
|
|
|
ArrayList<OverlayOptions> aslist = new ArrayList<OverlayOptions>();
|
|
|
|
|
|
|
|
aslist.add(option1);
|
|
|
|
|
|
|
|
aslist.add(option2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mBaiduMap.clear();
|
|
|
|
|
|
|
|
overlayManager.setData(aslist);
|
|
|
|
|
|
|
|
mBaiduMap.setOnMarkerClickListener(overlayManager);
|
|
|
|
|
|
|
|
overlayManager.addToMap();
|
|
|
|
|
|
|
|
if( exe_count < 3) {
|
|
|
|
|
|
|
|
overlayManager.zoomToSpan();
|
|
|
|
|
|
|
|
mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(new LatLng((point1.latitude + point2.latitude) / 2, (point1.longitude + point2.longitude) / 2)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onMessageReceive(List<MessageEvent> list) {
|
|
|
|
|
|
|
|
Logger.i("聊天页面接收到消息:" + list.size());
|
|
|
|
|
|
|
|
//当注册页面消息监听时候,有消息(包含离线消息)到来时会回调该方法
|
|
|
|
|
|
|
|
for (int i=0;i<list.size();i++){
|
|
|
|
|
|
|
|
process_recv_msg( list.get(i));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void process_recv_msg(MessageEvent event) {
|
|
|
|
|
|
|
|
Logger.i( "we are in process recv msg\n");
|
|
|
|
|
|
|
|
BmobIMMessage msg =event.getMessage();
|
|
|
|
|
|
|
|
if( msg.getMsgType().equals("location")) {
|
|
|
|
|
|
|
|
Logger.i( "获取的msg的类型:" + msg.getMsgType() );
|
|
|
|
|
|
|
|
BmobIMLocationMessage recv_loc_msg = BmobIMLocationMessage.buildFromDB( msg );
|
|
|
|
|
|
|
|
friend_loc = new LatLng(recv_loc_msg.getLatitude(), recv_loc_msg.getLongitude());
|
|
|
|
|
|
|
|
refresh_map();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class LocationEntity {
|
|
|
|
class LocationEntity {
|
|
|
|
BDLocation location;
|
|
|
|
BDLocation location;
|
|
|
|
long time;
|
|
|
|
long time;
|
|
|
|