recon my own marker

This commit is contained in:
Adam Domagalski 2018-11-17 19:56:57 +01:00
parent bb4831ec89
commit 49f47986f0

View File

@ -99,13 +99,14 @@ public class MapActivity extends BaseActivity
private int zoomParam = 17; private int zoomParam = 17;
private int bearingParam = 180; private int bearingParam = 180;
private int tiltParam = 30; private int tiltParam = 30;
private String myID;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE); final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
myID = PrefUtils.getUserId(getApplicationContext());
// fetching coords service // fetching coords service
coordinateService = ApiClient.getClient(getApplicationContext()) coordinateService = ApiClient.getClient(getApplicationContext())
.create(CoordinateService.class); .create(CoordinateService.class);
@ -241,6 +242,9 @@ public class MapActivity extends BaseActivity
PrefUtils.getLocationLevel(getApplicationContext()) PrefUtils.getLocationLevel(getApplicationContext())
); );
Log.e(tag, "tutajMANUALid: " + PrefUtils.getUserId(getApplicationContext()));
Log.e(tag, "tutajMANUALid: " + myID);
disposable.add( disposable.add(
coordinateService coordinateService
.postCoordinate(droppedMarkercoordinate) .postCoordinate(droppedMarkercoordinate)
@ -339,7 +343,6 @@ public class MapActivity extends BaseActivity
private void fetchTopCoords() { private void fetchTopCoords() {
disposable.add( disposable.add(
// coordinateService.getTopCoordinates() // coordinateService.getTopCoordinates()
coordinateService.getOnlineCoordinates() coordinateService.getOnlineCoordinates()
@ -351,18 +354,17 @@ public class MapActivity extends BaseActivity
public void onSuccess(List<Coordinate> coordsList) { public void onSuccess(List<Coordinate> coordsList) {
if (droppedMarker != null) { if (droppedMarker != null) {
Timber.e("coordsList.add(droppedMarkercoordinate);");
coordsList.add(droppedMarkercoordinate); coordsList.add(droppedMarkercoordinate);
} }
if (coordsList.isEmpty() && droppedMarker == null) { if (coordsList.isEmpty() && droppedMarker == null) {
Log.e(tag, "200 empty []"); Timber.e("200 empty []");
mapboxMap.clear(); mapboxMap.clear();
return; return;
} }
ArrayList<String> tmp = new ArrayList<>(); ArrayList<String> tmp = new ArrayList<>();
for (Coordinate coordinate : coordsList) { for (Coordinate coordinate : coordsList) {
tmp.add(coordinate.getUserId()); tmp.add(coordinate.getUserId());
@ -429,9 +431,17 @@ public class MapActivity extends BaseActivity
Log.e(tag, "Marker Added: " + id); Log.e(tag, "Marker Added: " + id);
coordsMap.put(id, element); coordsMap.put(id, element);
Marker marker = mapboxMap.addMarker(new MarkerOptions()
MarkerOptions markerOptions = new MarkerOptions()
.title(id) .title(id)
.position(new LatLng(element.getLatitude(), element.getLongitude()))); .position(new LatLng(element.getLatitude(), element.getLongitude()));
// Check if this is me
if (id.equals(myID)) {
Icon icon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.blue_marker);
markerOptions.setIcon(icon);
}
Marker marker = mapboxMap.addMarker(markerOptions);
markerHash.put(id, marker); markerHash.put(id, marker);
} }