izuki
11/8/2017 - 6:11 AM

GoogleMap(Google Maps Android v2 API)

GoogleMap(Google Maps Android v2 API)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MapActivity">

    <TextView
        android:text="filename: sample.jpg"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    <TextView
        android:text="経度: 59.0311"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    <TextView
        android:text="緯度: 130.1515666"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <fragment
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/mapFragment"
        android:name="com.google.android.gms.maps.MapFragment"/>

</LinearLayout>
public class MapActivity extends AppCompatActivity implements OnMapReadyCallback {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map_view);

        MapFragment mapFragment = (MapFragment) getFragmentManager()
                .findFragmentById(R.id.mapFragment);

        mapFragment.getMapAsync(this);
    }

    @Override
    public void onMapReady(GoogleMap googleMap) {
        GoogleMap mMap= googleMap;
    }
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="jp.co.mekei_zu.exifview">

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

    <application
        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">
        
        <!-- meta-dataをこの場所に設定する事を絶対に忘れない -->
        <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key"/>
        
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name=".ImageViewActivity">
        </activity>
        <activity android:name=".MapViewActivity">
        </activity>
    </application>
</manifest>