Introduction
The “enviroCar: Mapbox to MapLibre migration” project under Google Summer of Code 2024 aims to enhance the enviroCar Android application by adding support for multiple map providers, primarily focusing on MapLibre. The introduction of a new extensible and independent map module offers several key benefits:
- Risk Mitigation: Reduce dependency on a single provider, mitigating risks from policy changes or price hikes.
- Customization: Users and developers can choose their preferred map provider.
- Enhanced Coverage: Different providers may offer better coverage in specific areas.
- Increased Reliability: Ensure continuous service by switching providers if one fails.
The newly introduced map module allows users to select their preferred map provider and style, both during compile-time and run-time of the application. You may refer to my earlier introductory or mid-term blog posts for more information regarding this project. This final blog post covers the overall progress made during the coding period.
Project Goals
There were four major goals set for this project, which were crucial in guiding my work, and receiving support from my mentor when challenges arose. These goals have successfully been completed, and include: 1) source-code maintenance, 2) map module implementation, 3) application refactor and update, and 4) testing. The details of these goals will be discussed in the following sections.
-
Source-Code Maintenance
This goal had three sub tasks, all of which have been completed.
- Updating the project dependencies, Android Target/Compile SDK, Gradle, Android Gradle Plugin etc. to their latest available versions.
- Migrating the project to utilise Gradle Version Catalog. It is the recommended way of specifying dependencies in Android projects, which allows to specify dependencies and plugins in a scalable way. It makes dependency management easier for projects involving multiple modules (such as enviroCar).
- Migrating to Jetpack View Binding from now deprecated Butter Knife. This is necessary in order to run the project on newer Android Studio and JDK versions.
Notable Pull Requests
- Update Project Dependencies: #1000 (1000th pull-request to the project 🎉)
- Migrate to Gradle Version Catalog: #1001
- Migrate to Jetpack View Binding: #1002
-
Map Module Implementation
The new org.envirocar.map map module has been introduced into the project’s source code. It is written in 100% Kotlin and includes support for Mapbox as well as MapLibre. Since the map module is very flexible, support for other map providers can also be added in the future.
The following code snippet provides an idea of how the module can be used to display a map and interact with it:
<org.envirocar.map.MapView android:id="@+id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" /> val view = findViewById(R.id.mapView) val provider = ... // May be [MapboxMapProvider] or [MapLibreMapProvider] etc. val controller = view.getController(provider) controller.addPolyline( Polyline.Builder(POINTS) .withWidth(4.0F) .withColor(0xFF0D53FF.toInt()) .build() ) controller.addMarker(Marker.Builder(POINTS.first()).build()) controller.addMarker(Marker.Builder(POINTS.last()).build()) controller.notifyCameraUpdate( CameraUpdateFactory.newCameraUpdateBasedOnBounds( POINTS, 120.0F ) )
This exemplifies how easy it is to select a map provider at run-time, by supplying the required MapProvider e.g. MapLibreMapProvider, MapboxMapProvider etc. to the getController method of the MapView. Various features have been added into the map provider e.g. manipulating camera, listening to camera events, adding/removing markers, polylines, polygons etc., displaying current location and more. These features are backed by provider specific implementations.
Similarly, at compile-time, following options in the local.properties file may be used to enable or disable certain map providers (by default, all available map providers are enabled):
org.envirocar.map.enableMapbox=true org.envirocar.map.enableMapLibre=true
The UML diagrams in Figures 1 and 2 below provide more information about the implementation of the map module:
Figure 1. UML diagram for org.envirocar.map map module
Figure 2. UML diagram for location indicator in the org.envirocar.map map module
Further documentation on the map module can be found in this GitHub Repository.
Notable Pull Requests
- Added org.envirocar.map Module: #1003
- Added LocationIndicator in org.envirocar.map module to display current user location: #1006
- Added MapLibre support to org.envirocar.map module: #1008
- Added documentation for org.envirocar.map module: #1011
-
Application Refactor & Update
There are primarily 3 types of views in the enviroCar Android application, which display a map view one way or another. These include:
- Track list
- Track details
- Recording screen
Once the map module was ready, the next step was to refactor the enviroCar Android application to use it instead of Mapbox directly. This is important so that users can easily switch between multiple map providers that the map module supports.
An option has also been added to the application’s settings to change the map provider and its associated style during runtime, as shown in Figure 3.
Figure 3. Option in the enviroCar Android application’s settings to change map provider & style.
Thus, by changing the map provider, the application can be tailored to the user’s desired interface. Screenshots via the application can be seen in Figures 4 through 7 below:
MapLibre + OpenStreetMap
Figure 4. enviroCar Android application with MapLibre provider & OpenStreetMap style.
MapLibre + MapTiler (Basic)
Figure 5. enviroCar Android application with MapLibre provider & MapTiler (Basic) style.
Mapbox + Mapbox (Streets)
Figure 6. enviroCar Android application with Mapbox provider & Mapbox (Streets) style.
Mapbox + MapTiler (Basic)
Figure 7. enviroCar Android application with Mapbox provider & MapTiler (Basic) style.
Notable Pull Requests
- Refactor track list components to use org.envirocar.map module: #1004
- Refactor track details components to use org.envirocar.map module: #1005
- Refactor recording screen components to use org.envirocar.map module: #1007
- Added option to configure map provider & style in the application settings: #1010
-
Testing
The final goal of this project was to maintain a stable experience for users by doing proper testing of the implemented features; in the testing phase, there were no deviations in the functionality of the enviroCar Android application from the original application to the application with the project’s refactoring.
Summary and Future Scope
We set four major goals for this project, all of which I am happy to state have been completed. Although there were instances where I had to adapt my schedule due to unforeseen complications, I was still able to complete the project within a timely manner. An example of one key challenge I faced during the project had to do with the location indicator in the map module, which I had to implement for the recording screen of the enviroCar Android application. As I did not expect this task to be part of the map module, effective communication with my mentor was crucial in managing this challenge, amongst others. Keeping him informed about my progress and any potential delays helped me tremendously to stay on-tack, and receive guidance and support. Weekly sprint meetings were also a great way to discuss challenges.
While the primary goals for this project have been met, there is still room for improvements and enhancements of this work. In this regard, the following list provides potential avenues for future implementation:
- Adding support for more map providers such as Google Maps SDK for Android and OsmDroid etc. into the map module.
- Making improvements to the location indicator in the map module, such as smoothly animating changes in the user’s location.
- Adding an option in the application’s settings to specify a custom style or tile server for the map e.g. as URL.
- A good idea may be to self host a vector tile server, such as OpenMapTiles. This will make the enviroCar Android application completely independent from any commercial provider such as MapTiler (which is currently being used).
Final Remarks
This is the final week of Google Summer of Code 2024 and I am happy with the contributions that I have made to the project. Participating in Google Summer of Code as a contributor has been a meaningful experience, and I can definitely say is one thing I will be checking off my bucket-list.
enviroCar Android application’s source-code is fairly large and has been in development for quite some time. Working on this project has really allowed me to further improve and polish my Android development skills. As part of this project, I have become familiar with Agile software development as well.
I want to thank my mentor for this project, Mr. Sebastian Drost. Your feedback, insight, and support at every moment has been extremely helpful to me and the project. Every discussion with you has led to a better outcome. I am very glad that I had a chance to work with 52°North Spatial Information Research GmbH. I hope the work I have done serves well in the future.
You may connect with me on:
Leave a Reply