-
Notifications
You must be signed in to change notification settings - Fork 0
How to use the mapmd library
Mapmd edited this page May 8, 2019
·
4 revisions
MapMd MapView is basically a replacement for Mapbox MapView class. First of all, create your Android project, and follow HowToGradle if you're using Gradle/Android Studio. This will help you get the binaries for Mapmd included in your project.
If you are only using parts of the library, you can adjust the permissions accordingly. Online tile provider
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />Create a "src/main/res/layouts/main.xml" layout like this one. With Android Studio, it probably created one already. The default is called "src/main/res/layouts/activity_main.xml":
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.simpals.map.md.MapMdView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:layout_constraintEnd_toEndOf="parent"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="parent"
mapbox:mapbox_cameraTargetLat="47.003670"
mapbox:mapbox_cameraTargetLng="28.907089"
mapbox:mapbox_cameraZoom="11"
mapbox:mapbox_cameraZoomMax="21"
mapbox:mapbox_cameraZoomMin="6" />
</LinearLayout>We now create the main activity (MainActivity.java):
import com.simpals.map.md.MapMd;
import com.simpals.map.md.MapMdView;
public class MainActivity extends AppCompatActivity implements OnMapMdReadyCallback {
private MapMdView mapView;
private MapMd mapMd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapMd.getInstanceMap(this, "2582e284-1087-421c-baaa-94020703c462");
setContentView(R.layout.activity_main);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.initMap(this, this);
}
@Override
public void onMapReady(@NonNull MapboxMap mapMd) {
}
@Override
public void onStart() {
super.onStart();
mapView.onStart();
}
@Override
public void onResume() {
super.onResume();
mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mapView.onPause();
}
@Override
public void onStop() {
super.onStop();
mapView.onStop();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}
@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}
}