Commit c299e9f6 authored by Corentin Mors's avatar Corentin Mors
Browse files

Update overlays properly on movement

parent 685f40b9
......@@ -37,6 +37,7 @@ import org.osmdroid.views.overlay.Marker;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
......@@ -176,11 +177,16 @@ public class MainActivity extends AppCompatActivity {
locationMarker.setPosition(currentLocation);
locationMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
Drawable icon = getResources().getDrawable(R.drawable.ic_person_pin_circle_black_24dp);
icon.mutate();
icon.mutate(); // Make an separate instance of the drawable
icon.setTint(getUsernameColor(mUsername));
locationMarker.setIcon(icon);
locationMarker.setTitle("Your location");
map.getOverlays().clear();
map.getOverlays().add(locationMarker);
for (Marker value : userMarkers.values()) {
map.getOverlays().add(value);
}
}
}
......@@ -208,15 +214,20 @@ public class MainActivity extends AppCompatActivity {
Marker locationMarker = new Marker(map);
locationMarker.setPosition(uGeoPoint);
locationMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_CENTER);
locationMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
Drawable icon = getResources().getDrawable(R.drawable.ic_person_pin_circle_black_24dp);
icon.mutate();
icon.setTint(getUsernameColor(username));
locationMarker.setIcon(icon);
locationMarker.setTitle(username);
userMarkers.put(username, locationMarker);
map.getOverlays().clear();
map.getOverlays().add(locationMarker);
for (Marker value : userMarkers.values()) {
map.getOverlays().add(value);
}
}
......@@ -293,8 +304,8 @@ public class MainActivity extends AppCompatActivity {
"New Location \n Longitude: %1$s \n Latitude: %2$s",
loc.getLongitude(), loc.getLatitude()
);
Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show();
Log.e("OM_LOG", message);
// Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show();
// Log.e("OM_LOG", message);
currentLocation = new GeoPoint(loc);
currentLocation.setCoords(loc.getLatitude(), loc.getLongitude());
displayMyCurrentLocationOverlay();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment