0% found this document useful (0 votes)
53 views11 pages

Mapbox For Android: Anna Kasagawa, Monsurat Olaosebikan, and Rebecca Alpert

The document discusses Mapbox for Android, including displaying maps, navigation directions, and custom maps/markers. It provides a demo of adding a basic map with markers and navigation in Android using Mapbox. It outlines 6 steps: 1) Add permissions, 2) Add Mapbox SDK, 3) Add map component to XML, 4) Initialize map, 5) Add markers, and 6) Navigate between positions. The document demonstrates how to get started with basic mapping and navigation functionality using Mapbox for Android apps.

Uploaded by

eyayem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views11 pages

Mapbox For Android: Anna Kasagawa, Monsurat Olaosebikan, and Rebecca Alpert

The document discusses Mapbox for Android, including displaying maps, navigation directions, and custom maps/markers. It provides a demo of adding a basic map with markers and navigation in Android using Mapbox. It outlines 6 steps: 1) Add permissions, 2) Add Mapbox SDK, 3) Add map component to XML, 4) Initialize map, 5) Add markers, and 6) Navigate between positions. The document demonstrates how to get started with basic mapping and navigation functionality using Mapbox for Android apps.

Uploaded by

eyayem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Mapbox for Android

Anna Kasagawa, Monsurat Olaosebikan, and Rebecca Alpert


What is mapbox?
● Map, Search & Navigation SDKs for Android, iOS, Web

● Display Maps

● Navigation Directions (turn by turn, text to speech)

● Custom Maps & Markers


Demo :)
basic map with markers & navigation
Step 1 : Add permissions

AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />


<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Step 2 : Add the mapbox sdk to build.gradle

build.gradle (Module: app)

compile ('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.6.1') {
transitive = true
}
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.4@aar') {
transitive = true
}
compile 'com.mapbox.mapboxsdk:mapbox-android-services:2.2.6'
Step 3: Add map component to XML

content_main.xml

<Layout….>
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraTargetLat="42.40817"
mapbox:mapbox_cameraTargetLng="-71.11375"
mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v10"
mapbox:mapbox_cameraZoom="14" />
</Layout…>
Step 4 : Initialize map in onCreate

MainActivity.java (onCreate)
Mapbo
Mapbox.getInstance(this, ACCESS_TOKEN);
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
Step 5: Add markers
MainActivity.java (onCreate)

mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(42.4075, -71.1190))
.title("Tufts University")
.snippet("Welcome jumbos!"));
}
});
Step 6 : Navigate!

AndroidManifest.xml

Position origin = Position.fromCoordinates(-77.03613, 38.90992);


Position destination = Position.fromCoordinates(-77.0365, 38.8977);

NavigationLauncher.startNavigation(MainActivity.this, origin, destination, null, true);


Step 7 : Customize
Step 8: Profit!

You might also like