diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ee2c173..1bf42f0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -113,11 +113,11 @@ android:name=".PostActivity" android:exported="true" android:label="@string/title_activity_post"> - - + + - - + + { Log.d("debug", "currentbutton, 現在地にカメラを移動"); - //shopsViewModel.setViewArea(currentLatlng.longitude+20, currentLatlng.latitude+20.0, currentLatlng.longitude-20.0, currentLatlng.latitude-20.0); System.out.println(shopsViewModel.getShopsLiveData().getValue()); //現在地にカメラを移動 zoomMap(currentLatlng.latitude, currentLatlng.longitude); @@ -117,8 +115,6 @@ //ViewModelへのアクセス shopsViewModel = new ViewModelProvider(this).get(ShopsViewModel.class); - //ダミーショップaとcが返される座標にしておく - shopsViewModel.setViewArea(40.0, 140.0, 20.0, 100.0); // LiveDataへの購読 shopsViewModel.getShopsLiveData().observe(this, shops -> { @@ -139,7 +135,7 @@ }); - +/* //研究室周辺の緯度経度 double latitude = 34.7308032; double longitude = 135.2630272; @@ -148,14 +144,8 @@ testLatlng = new LatLng(latitude, longitude); testLatlng2 = new LatLng(34.74, 135.26); - //初期画面の座標(現在地をロードするまで) - initialLatlng = new LatLng(39,138); //店Cの座標にカメラ移動 -// initialLatlng = new LatLng(34.5,12.3); - - //初期画面に移動 - mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(initialLatlng, 15f)); - + //initialLatlng = new LatLng(34.5,12.3); //標準のマーカー(店用のピン) //setMarker(latitude, longitude); @@ -163,13 +153,23 @@ //アイコン画像をマーカーに設定 //画像関連がわかっていないのでパス //setIcon(latitude, longitude); + */ + + //初期画面の座標(現在地をロードするまで表示) + initialLatlng = new LatLng(39,138); + //初期画面に移動 + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(initialLatlng, 15f)); //画面が動いたとき mMap.setOnCameraIdleListener(() -> { //カメラの座標とZOOM倍率を保存 nowCamera = mMap.getCameraPosition(); + nemophila.setCameraLatitude(nowCamera.target.latitude); + nemophila.setCameraLongitude(nowCamera.target.longitude); + nemophila.setZoom(nowCamera.zoom); + nowLatlng = new LatLng(nowCamera.target.latitude, nowCamera.target.longitude); - nowZoom = nowCamera.zoom; + //nowZoom = nowCamera.zoom; //Shopの描画範囲を指定 shopsViewModel.setViewArea(nowLatlng.longitude+1, nowLatlng.latitude+1, nowLatlng.longitude-1, nowLatlng.latitude-1); }); @@ -198,19 +198,6 @@ //ShopCreate画面に遷移 Intent intent = new Intent(MainActivity.this, ShopCreateActivity.class); startActivity(intent); - - //遷移先でShopの作成中... - -// //Shopの作成が完了した場合。if~ -// //作成した店の座標を受け取る -// LatLng newlocation = new LatLng(nemophila.getCurrentLatitude(), nemophila.getCurrentLongitude()); -// //ピンをその座標に立て、緯度経度をタイトルに設定 -// //タイトルはnullにする予定 -// //↓返り値でMarkerを返すので、Nemophilaに渡す予定 -// Marker createMaker = mMap.addMarker(new MarkerOptions().position(newlocation).title(""+nemophila.getCurrentLatitude()+" :"+ nemophila.getCurrentLongitude())); -// //ピンを立てた位置にカメラを移動 -// mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(newlocation, 15)); - }); // ピンをクリックした場合 @@ -276,7 +263,7 @@ newLatLngBounds(bounds, width, height, 0)); //ズーム処理 - mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, nowZoom)); + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, nemophila.getZoom())); } //現在地の表示