Android/googlemap の変更点   


#author("2016-12-01T01:20:25+00:00","default:pentacle","pentacle")
* install [#za1b464e]

''build.gradle (app) ''
    defaultconfig{
            :
        multiDexEnabled true
    }
 
    // google map
    compile 'com.google.android.gms:play-services:9.8.0'
    compile 'com.android.support:multidex:1.0.1'

''AndroidManifest.xml''
#pre{{
  <application>
         <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key"/>
         <activity android:name=".MainActivity">
                  :
  </application>
}}

''res/values/google_maps_api.xml''
#pre{{
<resources>
    <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">【map key】</string>
</resources>
}}

''MainActivity.java''

  public class MainActivity extends FragmentActivity implements OnMapReadyCallback {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

''res/layout/activity_main.xml''
#pre{{
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:map="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          android:id="@+id/map"
          android:name="com.google.android.gms.maps.SupportMapFragment"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          tools:context=".MainActivity"/>
}}

* style [#udefb475]
 https://mapstyle.withgoogle.com/
で、スタイルを作成して下記に保存する

''res/raw/style_json.json''

''MainActivity.java''
#pre{{
  @Override 
  public void onMapReady(GoogleMap mMap){
        // map スタイルの設定
        mMap.setIndoorEnabled(false);
        try {
            boolean success = mMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(
                    this, R.raw.style_json));
            if (!success) {
                Log.e("MapsActivityRaw", "Style parsing failed.");
            }
        } catch (Resources.NotFoundException e) {
            Log.e("MapsActivityRaw", "Can't find style.", e);
        }
 } 
}}