SEARCH

Linux Install

Android

Linux Tools

Linux AV

Linux Memo

WINDOWS

PROGRAM

動画 Memo

音楽 Memo

モバイルアプリ Memo

FILE FORMAT

PROTOCOL

DEVICE

BookMark

その他


Android/googlemap   

install

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

  <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

<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

<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

https://mapstyle.withgoogle.com/

で、スタイルを作成して下記に保存する

res/raw/style_json.json

MainActivity.java

  @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);
        }
 }