trail-android

? Simple, smooth animation for route / polylines on google maps using projections.

Github stars Tracking Chart

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
  <fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.google.android.gms.maps.SupportMapFragment"/>
  <com.amalbit.trail.RouteOverlayView
    android:id="@+id/mapOverlayView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
</FrameLayout>

In your activity, create routes with three predefined styles as of now.

googleMap.setOnMapLoadedCallback(() -> {
    Route normalOverlayPolyline = new Route.Builder(mRouteOverlayView)
        .setRouteType(RouteType.PATH)
        .setCameraPosition(mMap.getCameraPosition())
        .setProjection(mMap.getProjection())
        .setLatLngs(mRoute)
        .setBottomLayerColor(Color.YELLOW)
        .setTopLayerColor(Color.RED)
        .create();

To make sure that the overlay moves along with the Google maps movement we need to add a hook from its cameramovelistener.

googleMap.setOnCameraMoveListener(() -> {
      mRouteOverlayView.onCameraMove(googleMap.getProjection(), googleMap.getCameraPosition());
    }
);

Library uses java 8 bytecode, so dont forget to enable java 8 in your application's build.gradle file.

android {
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

License

MIT © Amal Chandran

Jibin Joseph

Main metrics

Overview
Name With OwneramalChandran/trail-android
Primary LanguageJava
Program languageJava (Language Count: 2)
Platform
License:MIT License
所有者活动
Created At2016-12-26 16:10:15
Pushed At2020-02-03 16:02:06
Last Commit At2019-11-15 19:56:01
Release Count11
Last Release Namev1.53 (Posted on 2019-05-27 13:08:56)
First Release Namev1.0 (Posted on )
用户参与
Stargazers Count514
Watchers Count24
Fork Count128
Commits Count102
Has Issues Enabled
Issues Count29
Issue Open Count13
Pull Requests Count1
Pull Requests Open Count3
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private