diff --git a/app/src/main/java/com/example/nemophila/MainActivity.java b/app/src/main/java/com/example/nemophila/MainActivity.java index 2fa42ac..e50541f 100644 --- a/app/src/main/java/com/example/nemophila/MainActivity.java +++ b/app/src/main/java/com/example/nemophila/MainActivity.java @@ -7,7 +7,9 @@ import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; +import android.app.ProgressDialog; import android.os.Bundle; +import android.view.View; import android.widget.ImageButton; import android.widget.Toast; import android.annotation.SuppressLint; @@ -38,9 +40,10 @@ private GoogleMap mMap; private ActivityMainBinding binding; - private LatLng currentLatlng; + private LatLng currentLatlng = null; private LatLng testLatlng; private LatLng testLatlng2; + private LatLng initialLatlng; private GroundOverlay currentOverlay; LocationManager locationManager; @@ -49,8 +52,7 @@ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - //現在地アイコンの取得 - //Drawable ic_current = ResourcesCompat.getDrawable(getResources(),R.drawable.ic_current_location,null); + binding = ActivityMainBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); @@ -105,6 +107,12 @@ testLatlng = new LatLng(latitude, longitude); testLatlng2 = new LatLng(34.74, 135.26); + //初期画面の座標(現在地をロードするまで) + initialLatlng = new LatLng(39,138); + + //初期画面に移動 + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(initialLatlng, 5f)); + //標準のマーカー(店用のピン) setMarker(latitude, longitude); @@ -112,9 +120,6 @@ //画像関連がわかっていないのでパス //setIcon(latitude, longitude); - // camera 移動 (初期画面) - //mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 15)); - /* //多分使わない // タップした時のリスナーをセット @@ -171,7 +176,7 @@ } - //ピンの初期設定。完成時不要 + //起動時から立っているピンの設定。完成時不要 private void setMarker(double latitude, double longitude){ MarkerOptions markerOptions = new MarkerOptions(); MarkerOptions markerOptions2 = new MarkerOptions(); @@ -186,7 +191,7 @@ mMap.addMarker(markerOptions2); // ズーム - zoomMap(latitude, longitude); + //zoomMap(latitude, longitude); } @@ -310,8 +315,15 @@ @Override public void onLocationChanged(Location location) { + //初期画面は現在地を中心にするため... + if (currentLatlng == null){ + zoomMap(location.getLatitude(), location.getLongitude()); + findViewById(R.id.LL_Load).setVisibility(View.GONE); + + } + //現在地が変更されるたびに現在地アイコンを移動 - //LatLng型で一応受け取っておく + //LatLng型で受け取っておく currentLatlng = new LatLng(location.getLatitude(), location.getLongitude()); /*