This commit is contained in:
wangcongtao
2020-01-09 16:15:29 +08:00
5 changed files with 113 additions and 15 deletions

View File

@@ -9,7 +9,13 @@ import com.mogo.map.marker.IMogoMarkerManager;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.navi.IMogoNavi;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.module.service.entity.MarkerCarChat;
import com.mogo.module.service.entity.MarkerCardResult;
import com.mogo.module.service.entity.MarkerExploreWay;
import com.mogo.module.service.entity.MarkerLocation;
import com.mogo.module.service.entity.MarkerOnlineCar;
import com.mogo.module.service.entity.MarkerResponse;
import com.mogo.module.service.entity.MarkerShareMusic;
import com.mogo.module.service.marker.MapMarkerView;
import com.mogo.module.service.marker.MarkerInfoWindowAdapter;
import com.mogo.service.MogoServicePaths;
@@ -20,6 +26,8 @@ import com.mogo.service.map.IMogoMapService;
import com.mogo.utils.TipToast;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
@@ -32,7 +40,7 @@ import java.util.Random;
public class MarkerServiceHandler {
private static final String TAG = "MarkerServiceHandler";
private static MogoMarkerClickListener mogoMarkerClickListener;
private static MoGoMarkerClickListener mogoMarkerClickListener;
private static IMogoMapService mMapService;
private static IMogoMarkerManager mMarkerManager;
@@ -54,8 +62,7 @@ public class MarkerServiceHandler {
markerInfoWindowAdapter = new MarkerInfoWindowAdapter(context, getNavi(), getImageloader());
mMapUIController = mMapService.getMapUIController();
mogoMarkerClickListener = new MogoMarkerClickListener();
mogoMarkerClickListener = new MoGoMarkerClickListener();
// 长连接
mMogoSocketManager = (IMogoSocketManager) ARouter.getInstance().build(MogoServicePaths.PATH_SOCKET_MANAGER).navigation();
@@ -67,14 +74,58 @@ public class MarkerServiceHandler {
}
@Override
public void onMsgReceived(MarkerResponse obj) {
Logger.e("donghongyu", "===" + obj);
public void onMsgReceived(MarkerResponse response) {
Logger.e(TAG, "===" + response);
for (int i = 0; i < 10; i++) {
drawMapMarker();
getMarkerManager().removeMarkers();
// 解析不同的Marker类型然后对应的进行绘制
if (response != null && response.getResult() != null) {
MarkerCardResult markerCardResult = response.getResult();
List<MarkerCarChat> carChat = markerCardResult.getCarChat();
List<MarkerOnlineCar> onlineCar = markerCardResult.getOnlineCar();
List<MarkerExploreWay> exploreWay = markerCardResult.getExploreWay();
List<MarkerShareMusic> shareMusic = markerCardResult.getShareMusic();
ArrayList<MogoMarkerOptions> optionsList = new ArrayList<>();
if (carChat != null) {
for (MarkerCarChat markerCarChat : carChat) {
MarkerLocation markerLocation = markerCarChat.getLocation();
drawMapMarker(markerCarChat.getType(), markerLocation, optionsList);
}
}
if (onlineCar != null) {
for (MarkerOnlineCar markerOnlineCar : onlineCar) {
MarkerLocation markerLocation = markerOnlineCar.getLocation();
drawMapMarker(markerOnlineCar.getType(), markerLocation, optionsList);
}
}
if (exploreWay != null) {
for (MarkerExploreWay markerExploreWay : exploreWay) {
MarkerLocation markerLocation = markerExploreWay.getLocation();
drawMapMarker(markerExploreWay.getType(), markerLocation, optionsList);
}
}
if (shareMusic != null) {
for (MarkerShareMusic markerShareMusic : shareMusic) {
MarkerLocation markerLocation = markerShareMusic.getLocation();
drawMapMarker(markerShareMusic.getType(), markerLocation, optionsList);
}
}
List<IMogoMarker> iMogoMarkers = getMarkerManager().addMarkers(TAG, optionsList, true);
for (IMogoMarker iMogoMarker : iMogoMarkers) {
iMogoMarker.setInfoWindowAdapter(markerInfoWindowAdapter);
iMogoMarker.setOnMarkerClickListener(mogoMarkerClickListener);
}
}
}
}
});
}
@@ -106,7 +157,7 @@ public class MarkerServiceHandler {
/**
* 地图上的Marker点击回调
*/
static class MogoMarkerClickListener implements IMogoMarkerClickListener {
static class MoGoMarkerClickListener implements IMogoMarkerClickListener {
@Override
public boolean onMarkerClicked(IMogoMarker marker) {
@@ -117,14 +168,39 @@ public class MarkerServiceHandler {
}
public static void drawMapMarker() {
TipToast.shortTip("绘制Marker");
/**
* 绘制Marker
*
* @param markerTag Marker类型
* http://gitlab.zhidaoauto.com/ecos/yycp-service/CarLauncher-Docs/blob/master/%E5%8D%A1%E7%89%87%E7%B1%BB%E5%9E%8B%E5%AE%9A%E4%B9%89.md
* @param markerLocation 要绘制Marker的位置信息
* @param optionsList 要加入的Marker集合
*/
public static void drawMapMarker(String markerTag, MarkerLocation markerLocation,
ArrayList<MogoMarkerOptions> optionsList) {
Logger.e(markerTag, "绘制Marker====markerTag" + markerTag);
MapMarkerView mapMarkerView = new MapMarkerView(mContext);
MogoMarkerOptions options = new MogoMarkerOptions()
.icon(mapMarkerView)
.owner(TAG)
.owner(markerTag)
.latitude(markerLocation.getLat())
.longitude(markerLocation.getLon());
optionsList.add(options);
}
//TODO 这里是用来测试的
public static void drawMapMarker() {
Logger.e(TAG, "=====绘制Marker====");
MapMarkerView mapMarkerView = new MapMarkerView(mContext);
MogoMarkerOptions options = new MogoMarkerOptions()
.icon(mapMarkerView)
.owner("CARD_TYPE_USER_DATA")
.latitude(39.574525d + new Random().nextDouble())
.longitude(116.21733d + new Random().nextDouble());
IMogoMarker marker = getMarkerManager().addMarker(TAG, options);
@@ -132,5 +208,8 @@ public class MarkerServiceHandler {
marker.setOnMarkerClickListener(mogoMarkerClickListener);
getMapUIController().changeZoom(false);
getMapUIController().changeZoom(10);
}
}