@Override public void updateMarker(MarkerInfo markerInfo, boolean isDraggable) { // if the drone hasn't received a gps signal yet final Coord2D coord = markerInfo.getPosition(); if (coord == null) { return; } final LatLng position = DroneHelper.CoordToLatLng(coord); Marker marker = mBiMarkersMap.getValue(markerInfo); if (marker == null) { marker = new Marker(mMapView, markerInfo.getTitle(), markerInfo.getSnippet(), position); mMarkersOverlay.addItem(marker); mBiMarkersMap.put(markerInfo, marker); } else { marker.setTitle(markerInfo.getTitle()); marker.setDescription(markerInfo.getSnippet()); marker.setPoint(position); } // Update the marker final Resources res = getResources(); Bitmap markerIcon = markerInfo.getIcon(res); if (markerIcon == null) { markerIcon = BitmapFactory.decodeResource(res, R.drawable.ic_action_location); } marker.setIcon(new Icon(new BitmapDrawable(res, markerIcon))); marker.setAnchor(new PointF(markerInfo.getAnchorU(), markerInfo.getAnchorV())); marker.invalidate(); mMapView.invalidate(); }
@Override public void onMarkerDragStart(Marker marker) { if (mMarkerDragListener != null) { final MarkerInfo markerInfo = mBiMarkersMap.getKey(marker); markerInfo.setPosition(DroneHelper.ILatLngToCoord(marker.getPoint())); mMarkerDragListener.onMarkerDragStart(markerInfo); } }
@Override public void removeMarkers(Collection<MarkerInfo> markerInfoList) { if (markerInfoList == null || markerInfoList.isEmpty()) { return; } final List<Marker> markersToRemove = new ArrayList<Marker>(markerInfoList.size()); for (MarkerInfo markerInfo : markerInfoList) { final Marker marker = mBiMarkersMap.getValue(markerInfo); if (marker != null) { markersToRemove.add(marker); mBiMarkersMap.removeKey(markerInfo); } } removeMarkersOverlay(markersToRemove); mMapView.invalidate(); }
@Override public void onTapMarker(MapView pMapView, final Marker pMarker) { if (mMarkerClickListener != null) { mMarkerClickListener.onMarkerClick(mBiMarkersMap.getKey(pMarker)); } }
@Override public Set<MarkerInfo> getMarkerInfoList() { return new HashSet<MarkerInfo>(mBiMarkersMap.keySet()); }
@Override public void clearMarkers() { resetMarkersOverlay(); mBiMarkersMap.clear(); mMapView.invalidate(); }