Vector Maps for Android Apps
Advanced User Setup
Using MapLibre SDK for Native apps
MapLibre SDK
MapLibre is an open source project that was forked from Mapbox GL SDK. It is our preferred mapping program for interactive maps due to its modern design and ease of use.
Link | Description |
---|---|
Homepage | The Projects home for Native SDK |
SDK Reference | Information, examples, and plugins |
Github | Source code |
Use the code below for a quick and easy setup.
New Project Setup
This project will setup a basic interactive map using the MapLibre SDK. Start a new project with the settings below.
Item | Description |
---|---|
Language | Kotlin |
Minimum SDK | API 14 or newer |
Add Dependencies
Follow the instructions for adding dependencies to your project.
Instructions |
---|
From the top drop-down, select File -> Project Structure |
n the Project Structure window, choose Dependencies, then <All Modules>. |
Click + Add Dependency from the <All Modules> column, and then choose Library Dependency from the drop-down. |
Enter org.maplibre.gl:android-sdk: and click Search. Choose the latest version and click OK |
Note: The latest current Android version can be found on the MapLibre SDK release page. |
Repeat clicking + Add Dependency from the <All Modules> column, and then choose Library Dependency from the drop-down. |
Enter com.squareup.okhttp3:okhttp: and click Search. Choose the latest version and click OK |
Your Project build.gradle should now contain the "mavenCentral()" repository. |
Your Module build.gradle should now contain the "org.maplibre.gl:android-sdk:x.x.x" and "com.squareup.okhttp3:okhttp:x.x.x" implementation. |
Setup Layout
Instructions |
---|
From the Project File Navigation Panel, navigate to app -> res -> layout and open activity_{type}.xml |
Note: The activity xml file name is based on the type selected when starting the project. ie - Basic, Empty, or Fullscreen Activity. |
Using Code view, Add the MapView code below within the main Layout, and replace any existing TextViews or other Views. |
Attribution
The next Activity section will already include the links below.
Our maps are built with the
help of thousands of public and private sources and open projects. Allowing it's display
satisfies their required attributions.
Setup Activity
Instructions |
---|
From the Project File Navigation Panel, navigate to app -> java -> com.examply.{projectname} and open {type}Activity |
Note: The activity file name is based on the type selected when starting the project. ie - Basic, Empty, or Fullscreen Activity. |
Click ... next to import, and add the import code below the other import lines. |
Within the main AppCompatActivity() class, modify or replace the onCreate function with the onCreate code below. |
Note: Change the Api Key, center, zoom, language, and R.layout.activity_{type} to match your needs. | Within the main AppCompatActivity() class, add override code for App events. |
Import Section
onCreate
overrides
Build and Run
That's it. You should have a working interactive map.
Next Steps
Customize and add features to your new map
Settings & Features
- Common settings and Language Support.
- Content Filtering
- Satellite, Street Level, and other features.
- Compatibility for older browsers.
Map Design
- Customize your maps look
- Night Mode, Greyscale.
- Get the Slpy Style source code.
Search & Geocoding
- Add a search bar to your map.
- Translate addresses to coordinates
- Search for points of interest.