前回までで、Javaクラスのソースについては全部終わりました。
今回は、それ以外のファイルについてです。プロジェクト名は今回の場合"mpf_rotation7"です。
Manifest
Manifestはこんな感じです。GPSと外部ファイルへのアクセス許可。アクティビティの登録などを追記しています。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mpf_rotation7">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name="com.example.mpf_rotation7.SamplesApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.example.mpf_rotation7.RotateMapViewer"></activity>
<activity android:name="com.example.mpf_rotation7.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.mpf_rotation7.SimplestMapViewer"
android:configChanges="keyboardHidden|orientation|screenSize" />
<activity
android:name="com.example.mpf_rotation7.OverlayMapViewer"
android:configChanges="keyboardHidden|orientation|screenSize" />
</application>
</manifest>
gradle
gradleについては依存関係の部分だけを記します。ここにmapsforgeのライブラリを登録しておく必要があります。
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'org.mapsforge:mapsforge:0.6.1'
implementation 'org.mapsforge:mapsforge-core:0.11.0'
implementation 'org.mapsforge:mapsforge-map:0.11.0'
implementation 'org.mapsforge:mapsforge-map-reader:0.11.0'
implementation 'org.mapsforge:mapsforge-themes:0.11.0'
implementation 'net.sf.kxml:kxml2:2.3.0'
implementation 'org.mapsforge:mapsforge-map-android:0.11.0'
implementation 'com.caverock:androidsvg:1.3'
}
リソースファイル
リソースファイルが山ほどあるので順番に。
drawable
drawableはアプリ内で使用する画像ファイルです。

このうちleft1からleft8とright1からright8まではPOIで地図上に右折、左折を表示させるための矢印の画像でパワポで自作しました。
それ以外は、mapsforgeのサイトからコピーしたものです。marker_greenとmarker_redはそれぞれ緑と赤のバルーンで、本質的には必要ないものです。一応”Overlaymapviewer"のところで使ってはいるのでないとエラーになってしまいますが、サンプルプログラムをそのままコピペしているために必要なだけで、その部分を削除してしまえばエラーは解消します。
layout
画面はメニューを表示するMainActivityと地図を表示するRotateMapViewerがあるのでそれぞれにレイアウトファイルが必要です。実際のプロジェクトには4つファイルがあって2つほどゴミが残っていますが(笑)。
Activity_main.xmlはメニュー画面のボタンとGPSのオンオフ(といってもGPSそのものをオンオフするわけではなく、単にGPSの位置情報を地図に反映させるかどうか)のラジオボタンをRelativeLayoutで配置しています。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/btRotationalView"
android:layout_width="217dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="105dp"
android:layout_marginLeft="105dp"
android:layout_marginTop="215dp"
android:text="@string/RotationalView" />
<Button
android:id="@+id/btMapFileSelect"
android:layout_width="214dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="105dp"
android:layout_marginLeft="105dp"
android:layout_marginTop="101dp"
android:text="Map File Select" />
<Button
android:id="@+id/btGPXSelect"
android:layout_width="214dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="107dp"
android:layout_marginLeft="107dp"
android:layout_marginTop="426dp"
android:text="GPX File Select" />
<RadioGroup
android:id="@+id/radiogroup"
android:layout_width="262dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="83dp"
android:layout_marginLeft="83dp"
android:layout_marginTop="317dp"
android:layout_marginBottom="10dp"
android:background="#df7401"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<RadioButton
android:id="@+id/rbOn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:background="#ffffff"
android:text="@string/onGPS" />
<RadioButton
android:id="@+id/rbOff"
android:layout_width="101dp"
android:layout_height="match_parent"
android:background="#ffffff"
android:text="@string/offGPS" />
</RadioGroup>
<Button
android:id="@+id/btPOISelect"
android:layout_width="214dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="107dp"
android:layout_marginLeft="107dp"
android:layout_marginTop="547dp"
android:text="POI FILE SELECT" />
</RelativeLayout>rotatemapviewer.xmlはmapsforgeのサンプルをほぼコピペしています。やっていることはよくわかりません(笑)。地図画面とスケールを切り替えるプラスとマイナスのボタン。それにOpenStreetMapのクレジット表示があります。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainView"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.mapsforge.map.android.rotation.RotateView
android:id="@+id/rotateView"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.mapsforge.map.android.view.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</org.mapsforge.map.android.rotation.RotateView>
<com.example.mpf_rotation7.MapScaleBarView
android:id="@+id/mapScaleBarView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp" />
<ImageButton
android:id="@+id/zoomOutButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@android:color/transparent"
android:src="@drawable/zoom_control_out" />
<ImageButton
android:id="@+id/zoomInButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/zoomOutButton"
android:layout_alignParentRight="true"
android:background="@android:color/transparent"
android:src="@drawable/zoom_control_in" />
<TextView
android:id="@+id/attribution"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/attribution_margin"
android:gravity="center"
android:singleLine="true"
android:text="@string/copyright_osm"
android:textColor="#000"
android:textSize="@dimen/attribution_size" />
</RelativeLayout>
mipmap
mipmapのファイルもすべてMapsforgeのサイトからのコピペです。

values
valuesにもいっぱいファイルがありますが、使っていないのがありそうです。

絶対に使っているのはstrings.xmlとdimens.xmlの2つです。しかもstrings.xmlのなかにもゴミがいっぱい。コピペしたのに必要なものだけ追記しているので、こんなの絶対使ってないだろというのがいっぱいあります。
一応全文を載せると。
<resources>
<string name="app_name">mpf_Rotation4</string>
<string name="RotationalView">RotationalView</string>
<string name="copyright_osm">Map data © OpenStreetMap contributors</string>
<string name="onGPS">GPS On</string>
<string name="offGPS">GPS Off</string>
<string name="menu_preferences">Settings</string>
<string name="menu_position_enter_coordinates">Map Position</string>
<string name="menu_svgclear">Clear SVG icon cache</string>
<string name="cancelbutton">Cancel</string>
<string name="okbutton">OK</string>
<string name="downloadnowbutton">OK</string>
<string name="rotate_button">Rotate</string>
<string name="zoomin_button">+</string>
<string name="zoomout_button">-</string>
<string name="latitude">Latitude</string>
<string name="longitude">Longitude</string>
<string name="zoomlevel">Zoom Level</string>
<string name="preferences_scale">Display Scale</string>
<string name="preferences_scale_desc">Adjust scale of the map display</string>
<string name="preferences_language">Multilingual Map Language Selection</string>
<string name="preferences_language_desc">Select language of multilingual map (multilingual map must be loaded)</string>
<string name="preferences_language_showlocal">Language Display Style</string>
<string name="preferences_language_showlocal_desc">Show both local and preferred language</string>
<string name="preferences_scalebar">Scale bar</string>
<string name="preferences_scalebar_desc">Set units system on the scale bar</string>
<string name="preferences_textwidth">Maximum Textwidth</string>
<string name="preferences_textwidth_desc">Debugging aid for setting maximum textwidth</string>
<string name="preferences_category_wayfiltering">Way filtering</string>
<string name="preferences_wayfiltering">Way filtering</string>
<string name="preferences_wayfiltering_desc">Way filtering reduces the number of ways returned at the risk of clipping artifacts</string>
<string name="preferences_wayfiltering_distance">Way filter size</string>
<string name="preferences_wayfiltering_distance_desc">The higher the number the less artifacts, but slower</string>
<string name="preferences_category_tilecache">Tile cache</string>
<string name="preferences_tilecache_persistence">Persistence</string>
<string name="preferences_tilecache_persistence_desc">Keep tiles over activity restart</string>
<string name="preferences_debug_timing">Debug timing</string>
<string name="preferences_debug_timing_desc">Measure rendering time</string>
<string name="preferences_rendering_threads">Number of threads to render concurrently</string>
<string name="preferences_rendering_threads_desc">Minimum 1</string>
<string name="preferences_r4_emergency">Emergency</string>
<string name="preferences_r4_emergency_desc">Show hospitals, doctors, police etc</string>
<string name="preferences_r4_accommodation">Accommodation</string>
<string name="preferences_r4_accommodation_desc">Show hostels, guesthouses, campsites etc</string>
<string name="preferences_r4_tourism_poi">Tourism</string>
<string name="preferences_r4_tourism_poi_desc">Show points of interest</string>
<string name="preferences_r4_shopping">Shopping</string>
<string name="preferences_r4_shopping_desc">Show shops</string>
<string name="preferences_r4_amenities">Amenities</string>
<string name="preferences_r4_amenities_desc">Show amenities???</string>
<string name="preferences_r4_public_transport">Transport</string>
<string name="preferences_r4_public_transport_desc">Show transport</string>
<string name="preferences_r4_food">Food</string>
<string name="preferences_r4_food_desc">Show restaurants</string>
<string name="preferences_r4_traffic">Traffic</string>
<string name="preferences_r4_traffic_desc">Show traffic/transport??</string>
<string name="preferences_r4_barriers">Barriers</string>
<string name="preferences_r4_barriers_desc">Show barriers</string>
<string name="preferences_r4_sports">Sports</string>
<string name="preferences_r4_sports_desc">Show sports facilities</string>
<string name="preferences_r4_places">Places</string>
<string name="preferences_r4_places_desc">Show place names</string>
<string name="preferences_r4_buildings">Buildings</string>
<string name="preferences_r4_buildings_desc">Show buildings</string>
<string name="preferences_r4_nature">Nature</string>
<string name="preferences_r4_nature_desc">Show natural items</string>
<string name="preferences_r4_areas">Areas</string>
<string name="preferences_r4_areas_desc">Show areas</string>
<string name="preferences_r4_roads">Roads</string>
<string name="preferences_r4_roads_desc">Show roads</string>
<string name="preferences_r4_waterbodies">Water</string>
<string name="preferences_r4_waterbodies_desc">Show lakes, rivers etc</string>
<string name="dialog_location_title">Coordinates</string>
<string name="dialog_reverse_geocoding_title">Reverse Geocoding</string>
<string name="startup_dontshowagain">Don\'t show again</string>
<string name="startup_message">To run this samples app, you need any map with filename berlin.map installed on storage.\n\nadb push file.map /sdcard/Android/data/org.mapsforge.samples.android/files/berlin.map</string>
<string name="startup_message_tilestore">To run this sample activity, you need a TMS tile store at /sdcard/Android/data/org.mapsforge.samples.android/files/tilestore. Sample data in the app data directory.</string>
<string name="startup_message_multimap">To run this sample activity, you need to download a low-resolution world map first.</string>
<string name="startup_message_twomaps">To run this sample activity, you need also a map with filename second.map installed on storage.</string>
<string name="startup_message_poi">To run this sample activity, you need any poi with filename berlin.poi installed on storage.\n\nadb push file.poi /sdcard/Android/data/org.mapsforge.samples.android/files/berlin.poi</string>
</resources>dimens.xmlはシンプルで
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="attribution_margin">1dp</dimen>
<dimen name="attribution_size">4pt</dimen>
<dimen name="controls_margin">8dp</dimen>
</resources>これ以外に、menuの下にoptions_menu.xmlとxmlの下にpreferences.xmlがありますが、これらも使ってなさそう。

なんでこんなにゴミばっかりになったのか不明ですが、とりあえすこれで動いていうのでまあいいかなと。
一応ここまでで総括は終わりです。使っているうちに不便なところも出てきたので現在そのあたりを修正しています。
近いうちにまた修正版をアップする予定です。