Skip to content

Commit

Permalink
#45 puts the selected field paper page overlay in front of the others…
Browse files Browse the repository at this point in the history
…, but behind the osm overlays
  • Loading branch information
hallahan committed Apr 22, 2016
1 parent 4a0b206 commit 158045e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions MapboxAndroidSDK/src/main/java/org/fieldpapers/model/FPAtlas.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import com.mapbox.mapboxsdk.overlay.PathOverlay;
import com.mapbox.mapboxsdk.views.MapView;
import com.mapbox.mapboxsdk.views.MapViewListener;
import com.spatialdev.osm.marker.OSMItemizedIconOverlay;
import com.spatialdev.osm.renderer.OSMLine;
import com.spatialdev.osm.renderer.OSMOverlay;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
Expand Down Expand Up @@ -173,6 +175,26 @@ private void setSelectedPathOverlay(FPPage page) {
selectedPathOverlay.getPaint().setColor(Color.BLACK);
}
PathOverlay pathOverlay = page.pathOverlay();
List<Overlay> overlays = mapView.getOverlays();

// Remove overlay to select and then put it in the right place in the list
// so that it is in front of the other PathOverlays but behind the OSM
// overlays.
overlays.remove(pathOverlay);
int len = overlays.size();
boolean overlayMoved = false;
for (int i = 0; i < len; ++i) {
Overlay o = overlays.get(i);
if (o instanceof OSMOverlay || o instanceof OSMItemizedIconOverlay) {
overlays.add(i-1, pathOverlay);
overlayMoved = true;
break;
}
}
if (!overlayMoved) {
overlays.add(pathOverlay);
}

pathOverlay.getPaint().setARGB(255, OSMLine.DEFAULT_R, OSMLine.DEFAULT_G, OSMLine.DEFAULT_B);
selectedPathOverlay = pathOverlay;
}
Expand Down

0 comments on commit 158045e

Please sign in to comment.