-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
マップの表示 #26
base: master
Are you sure you want to change the base?
マップの表示 #26
Changes from 1 commit
cb97efb
0df851d
511b5fe
efb64f7
e03bc41
10de68a
330b9f3
c4f6472
229fd6a
591a39f
bf7af24
25be5b8
a062bed
e380bc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,4 @@ gradlew | |
gradlew.bat | ||
local.properties | ||
/build | ||
*.apk | ||
*.apk | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/build | ||
/build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ android { | |
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
manifestPlaceholders = [API_KEY: System.getenv("API_KEY")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. APIKEYを隠すのはGood!! |
||
} | ||
buildTypes { | ||
release { | ||
|
@@ -25,10 +26,11 @@ android { | |
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation 'androidx.appcompat:appcompat:1.0.2' | ||
implementation 'androidx.core:core-ktx:1.0.2' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
implementation 'com.google.android.gms:play-services-maps:16.1.0' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.0' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<resources> | ||
<!-- | ||
TODO: Before you run your application, you need a Google Maps API key. | ||
|
||
To get one, follow this link, follow the directions and press "Create" at the end: | ||
|
||
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=DF:33:9C:AE:13:E3:2D:FC:53:99:11:F7:30:0F:81:22:E1:E2:A6:01%3Bcom.example.kanazawaapp_2019 | ||
|
||
You can also add your credentials to an existing key, using these values: | ||
|
||
Package name: | ||
DF:33:9C:AE:13:E3:2D:FC:53:99:11:F7:30:0F:81:22:E1:E2:A6:01 | ||
|
||
SHA-1 certificate fingerprint: | ||
DF:33:9C:AE:13:E3:2D:FC:53:99:11:F7:30:0F:81:22:E1:E2:A6:01 | ||
|
||
Alternatively, follow the directions here: | ||
https://developers.google.com/maps/documentation/android/start#get-key | ||
|
||
Once you have your key (it starts with "AIza"), replace the "google_maps_key" | ||
string in this file. | ||
--> | ||
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">Your Api Key</string> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,42 @@ | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.kanazawaapp_2019"> | ||
|
||
<!-- | ||
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use | ||
Google Maps Android API v2, but you must specify either coarse or fine | ||
location permissions for the 'MyLocation' functionality. | ||
--> | ||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".FirstDescriptionActivity"></activity> | ||
|
||
<!-- | ||
The API key for Google Maps-based APIs is defined as a string resource. | ||
(See the file "res/values/google_maps_api.xml"). | ||
Note that the API key is linked to the encryption key used to sign the APK. | ||
You need a different API key for each encryption key, including the release key that is used to | ||
sign the APK for publishing. | ||
You can define the keys for the debug and release targets in src/debug/ and src/release/. | ||
--> | ||
<meta-data | ||
android:name="com.google.android.geo.API_KEY" | ||
android:value="${API_KEY}" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. API_KEY管理ちゃんとできてるのgoodです 👍 |
||
|
||
<activity | ||
android:name=".ShelterActivity" | ||
android:label="@string/shelterHeaderTitle"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".FirstDescriptionActivity" /> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.example.kanazawaapp_2019 | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
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 | ||
|
||
class ShelterActivity : AppCompatActivity(), OnMapReadyCallback { | ||
|
||
private lateinit var mMap: GoogleMap | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_shelter) | ||
// Obtain the SupportMapFragment and get notified when the map is ready to be used. | ||
val mapFragment = supportFragmentManager | ||
.findFragmentById(R.id.map) as SupportMapFragment | ||
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 fun onMapReady(googleMap: GoogleMap) { | ||
mMap = googleMap | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. なぜmMapという変数名にしたんですか? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. デフォルトの変数名をそのまま使いました。 |
||
|
||
// Add a marker in Sydney and move the camera | ||
val sydney = LatLng(-34.0, 151.0) | ||
mMap.addMarker(MarkerOptions().position(sydney).title("Marker in Sydney")) | ||
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this file keep layoutFolder |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<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=".ShelterActivity" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<resources> | ||
<string name="app_name">kanazawaApp-2019</string> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. キャメルケースになっていないよ。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 了解しました |
||
<string name="shelterHeaderTitle">避難所</string> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<resources> | ||
<!-- | ||
TODO: Before you release your application, you need a Google Maps API key. | ||
To do this, you can either add your release key credentials to your existing | ||
key, or create a new key. | ||
Note that this file specifies the API key for the release build target. | ||
If you have previously set up a key for the debug target with the debug signing certificate, | ||
you will also need to set up a key for your release certificate. | ||
Follow the directions here: | ||
https://developers.google.com/maps/documentation/android/signup | ||
Once you have your key (it starts with "AIza"), replace the "google_maps_key" | ||
string in this file. | ||
--> | ||
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">YOUR_KEY_HERE</string> | ||
</resources> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なんの差分?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あんまり意味なさげだから,上げない方がいいかも
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
了解しました