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)
@ -277,17 +281,17 @@ public class MapActivity extends BaseActivity
Toast.LENGTH_LONG Toast.LENGTH_LONG
).show(); ).show();
selectLocationButton.setBackgroundColor( selectLocationButton.setBackgroundColor(
ContextCompat.getColor(MapActivity.this, R.color.colorAccent)); ContextCompat.getColor(MapActivity.this, R.color.colorAccent));
selectLocationButton.setText("Remove Manual location"); selectLocationButton.setText("Remove Manual location");
selectLocationButton.setVisibility(View.VISIBLE); selectLocationButton.setVisibility(View.VISIBLE);
cancel[0] = true; cancel[0] = true;
} else { } else {
// TODO REMOVE Manual Location // TODO REMOVE Manual Location
mapboxMap.removeMarker(droppedMarker); mapboxMap.removeMarker(droppedMarker);
droppedMarker = null; droppedMarker = null;
droppedMarkercoordinate = null; droppedMarkercoordinate = null;
Toast.makeText( Toast.makeText(
MapActivity.this, MapActivity.this,
@ -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);
} }