Add map (OSM)
This commit is contained in:
parent
7f4b833496
commit
b5abd01dd2
@ -23,6 +23,7 @@ dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'org.osmdroid:osmdroid-android:6.1.5'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||
|
@ -24,4 +24,8 @@
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
</manifest>
|
@ -2,20 +2,34 @@ package io.dumpstack.minimap;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import org.osmdroid.config.Configuration;
|
||||
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
|
||||
import org.osmdroid.views.MapView;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements GestureDetector.OnGestureListener {
|
||||
|
||||
GestureDetector gestureDetector;
|
||||
private GestureDetector gestureDetector;
|
||||
private MapView map;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Context ctx = getApplicationContext();
|
||||
Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
map = findViewById(R.id.map);
|
||||
map.setTileSource(TileSourceFactory.MAPNIK);
|
||||
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().hide();
|
||||
}
|
||||
@ -26,6 +40,16 @@ public class MainActivity extends AppCompatActivity implements GestureDetector.O
|
||||
this.gestureDetector = new GestureDetector(this, this);
|
||||
}
|
||||
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
map.onResume();
|
||||
}
|
||||
|
||||
public void onPause(){
|
||||
super.onPause();
|
||||
map.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
if (gestureDetector.onTouchEvent(ev)) {
|
||||
|
@ -1,18 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout 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"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<org.osmdroid.views.MapView android:id="@+id/map"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user