マップを表示するところまで行きました。
ScrollViewが見えなくなっているので、そこだけ直せば行ける感じです。
取り敢えず動く範囲だけでプッシュします。
This commit is contained in:
oKikuti 2024-06-12 15:27:48 +09:00
parent 64f08d1c6c
commit 0f74ea09cf
9 changed files with 128 additions and 82 deletions

View File

@ -27,10 +27,14 @@
--> -->
<meta-data <meta-data
android:name="com.google.android.geo.API_KEY" android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY" /> android:value="AIzaSyBQ1Ak-I2NL5TP4K59ZI0VgzKk6HNZuusw" />
<activity <activity
android:name=".MapActivity" android:name=".Maps"
android:exported="false"
android:label="@string/title_activity_maps" />
<activity
android:name=".Map_Activity"
android:exported="false" /> android:exported="false" />
<activity <activity
android:name=".TutorialActivity" android:name=".TutorialActivity"

View File

@ -8,7 +8,6 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -20,18 +19,15 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// ID作成のTextViewとImageView // ID作成のTextViewとImageView
private TextView creatUUID; private TextView creatUUID;
private ImageView imageUuid; private ImageView imageUuid;
private int previousCreateUUid = 0; //元の画像のインデックス
// セットアップのTextViewとImageView // セットアップのTextViewとImageView
private TextView setUp; private TextView setUp;
private ImageView imageSetup; private ImageView imageSetup;
private int previousSetUp = 0; //元の画像のインデックス
// セットアップのTextViewとImageView // セットアップのTextViewとImageView
private TextView root; private TextView root;
private ImageView imageRoot; private ImageView imageRoot;
private int previousRoot = 0; //元の画像のインデックス
// 提出状況のTextViewとImageView // 提出状況のTextViewとImageView
private TextView submission; private TextView submission;
@ -94,7 +90,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// ルート作成のクリック処理 // ルート作成のクリック処理
if(view == root){ if(view == root){
imageRoot.setImageResource(R.drawable.pin); imageRoot.setImageResource(R.drawable.pin);
Intent toRoot = new Intent(MainActivity.this,RootSearchActivity.class); Intent toRoot = new Intent(MainActivity.this, Map_Activity.class);
startActivity(toRoot); startActivity(toRoot);
} }
// 提出状況のクリック処理 // 提出状況のクリック処理

View File

@ -1,14 +0,0 @@
package com.example.oplogy;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MapActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_activity);
}
}

View File

@ -0,0 +1,45 @@
package com.example.oplogy;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
public class Map_Activity extends AppCompatActivity implements View.OnClickListener, OnMapReadyCallback {
TextView toMain;
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_activity);
// ボタンの戻る処理
toMain = findViewById(R.id.toMain);
toMain.setOnClickListener(this);
}
@Override
public void onClick(View view) {
if(view == toMain){
Intent toMain = new Intent(Map_Activity.this,MainActivity.class);
startActivity(toMain);
}
}
@Override
public void onMapReady(@NonNull GoogleMap googleMap) {
mMap = googleMap;
}
}

View File

@ -0,0 +1,50 @@
package com.example.oplogy;
import androidx.fragment.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.example.oplogy.databinding.MapsBinding;
public class Maps extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private MapsBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = MapsBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}

View File

@ -1,57 +0,0 @@
package com.example.oplogy;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsFragment extends Fragment {
private OnMapReadyCallback callback = new OnMapReadyCallback() {
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera.
* In this case, we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to
* install it inside the SupportMapFragment. This method will only be triggered once the
* user has installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
LatLng sydney = new LatLng(-34, 151);
googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
};
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.maps_fragment, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
SupportMapFragment mapFragment =
(SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
if (mapFragment != null) {
mapFragment.getMapAsync(callback);
}
}
}

View File

@ -85,7 +85,7 @@
android:id="@+id/imageRoot" android:id="@+id/imageRoot"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/box_root" android:src="@drawable/pin"
android:layout_weight="1" android:layout_weight="1"
/> />
@ -104,7 +104,7 @@
<Space <Space
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="2"/> android:layout_weight="5"/>
<!-- 提出状況のレイアウト--> <!-- 提出状況のレイアウト-->
<TextView <TextView
@ -113,6 +113,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="提出状況" android:text="提出状況"
android:textSize="40dp" android:textSize="40dp"
android:textStyle="bold"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center" android:gravity="center"
android:layout_gravity="center"/> android:layout_gravity="center"/>

View File

@ -6,7 +6,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:weightSum="10" android:weightSum="10"
tools:context=".MapActivity"> tools:context=".Map_Activity">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -36,6 +36,26 @@
/> />
</LinearLayout> </LinearLayout>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/map_fragment_container"
tools:context=".Map"
android:layout_weight="6"
android:name="com.google.android.gms.maps.SupportMapFragment"
/>
<ScrollView
android:id="@+id/schoolName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
/>

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android" <fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/map" android:id="@+id/map"
tools:context=".MapsFragment" tools:context=".Maps"
android:name="com.google.android.gms.maps.SupportMapFragment"/> android:name="com.google.android.gms.maps.SupportMapFragment"/>