Skip to content

Commit

Permalink
Enhancement: Added directions to polylines when routing
Browse files Browse the repository at this point in the history
Upgraded gms:play-services-maps to 18.2.0 allows for arrows to be built into polylines which was previously not possible; this makes the directions of the routes easier to differentiate.

Fixes #910

Co-authored-by: Adithya-hv <[email protected]>
  • Loading branch information
aaronbrethorst and Adithya-hv committed Feb 28, 2024
1 parent a70deef commit d14ab11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion onebusaway-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ dependencies {
// Pelias for point-of-interest search and geocoding for trip planning origin and destination
implementation 'edu.usf.cutr:pelias-client-library:1.1.0'
// Google Play Services Maps (only for Google flavor)
googleImplementation 'com.google.android.gms:play-services-maps:18.0.2'
googleImplementation 'com.google.android.gms:play-services-maps:18.2.0'
// Google Play Services Places is required by ProprietaryMapHelpV2 (only for Google flavor)
googleImplementation 'com.google.android.libraries.places:places-compat:1.1.0'
// Autocomplete text views with clear button for trip planning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.UiSettings;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.MapStyleOptions;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.android.gms.maps.model.StampStyle;
import com.google.android.gms.maps.model.StrokeStyle;
import com.google.android.gms.maps.model.StyleSpan;
import com.google.android.gms.maps.model.TextureStyle;
import com.google.android.gms.maps.model.VisibleRegion;
import com.google.firebase.analytics.FirebaseAnalytics;

Expand Down Expand Up @@ -1038,12 +1043,18 @@ public void setRouteOverlay(int lineOverlayColor, ObaShape[] shapes, boolean cle
mLineOverlay.clear();
}
PolylineOptions lineOptions;
StampStyle polylineArrow = TextureStyle.newBuilder(
BitmapDescriptorFactory.fromResource(R.drawable.ic_navigation_expand_more)
).build();
StyleSpan polylineArrowSpan = new StyleSpan(
StrokeStyle.colorBuilder(lineOverlayColor).stamp(polylineArrow).build()
);

int totalPoints = 0;

for (ObaShape s : shapes) {
lineOptions = new PolylineOptions();
lineOptions.color(lineOverlayColor);
lineOptions.addSpan(polylineArrowSpan);

for (Location l : s.getPoints()) {
lineOptions.add(MapHelpV2.makeLatLng(l));
Expand Down

0 comments on commit d14ab11

Please sign in to comment.