Showing
7 changed files
with
174 additions
and
15 deletions
... | @@ -38,6 +38,7 @@ dependencies { | ... | @@ -38,6 +38,7 @@ dependencies { |
38 | compile 'com.android.support:design:25.3.1' | 38 | compile 'com.android.support:design:25.3.1' |
39 | compile 'com.squareup.picasso:picasso:2.5.2' | 39 | compile 'com.squareup.picasso:picasso:2.5.2' |
40 | compile 'com.google.firebase:firebase-messaging:11.0.2' | 40 | compile 'com.google.firebase:firebase-messaging:11.0.2' |
41 | + compile 'com.google.android.gms:play-services-maps:11.0.2' | ||
41 | testCompile 'junit:junit:4.12' | 42 | testCompile 'junit:junit:4.12' |
42 | } | 43 | } |
43 | 44 | ||
... | @@ -46,4 +47,5 @@ dependencies { | ... | @@ -46,4 +47,5 @@ dependencies { |
46 | 47 | ||
47 | 48 | ||
48 | 49 | ||
50 | + | ||
49 | apply plugin: 'com.google.gms.google-services' | 51 | apply plugin: 'com.google.gms.google-services' |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
app/src/debug/res/values/google_maps_api.xml
0 → 100644
1 | +<resources> | ||
2 | + <!-- | ||
3 | + TODO: Before you run your application, you need a Google Maps API key. | ||
4 | + | ||
5 | + To get one, follow this link, follow the directions and press "Create" at the end: | ||
6 | + | ||
7 | + https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=59:2E:80:8C:A4:7F:B6:08:C9:22:B7:C0:21:56:81:70:CB:42:9B:85%3Bcom.example.user.firebaseauthdemo | ||
8 | + | ||
9 | + You can also add your credentials to an existing key, using these values: | ||
10 | + | ||
11 | + Package name: | ||
12 | + 59:2E:80:8C:A4:7F:B6:08:C9:22:B7:C0:21:56:81:70:CB:42:9B:85 | ||
13 | + | ||
14 | + SHA-1 certificate fingerprint: | ||
15 | + 59:2E:80:8C:A4:7F:B6:08:C9:22:B7:C0:21:56:81:70:CB:42:9B:85 | ||
16 | + | ||
17 | + Alternatively, follow the directions here: | ||
18 | + https://developers.google.com/maps/documentation/android/start#get-key | ||
19 | + | ||
20 | + Once you have your key (it starts with "AIza"), replace the "google_maps_key" | ||
21 | + string in this file. | ||
22 | + --> | ||
23 | + <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false"> | ||
24 | + AIzaSyCThXzmOil0dxBRQupGmv1YLUi5VXqcr4w | ||
25 | + </string> | ||
26 | +</resources> |
... | @@ -2,9 +2,17 @@ | ... | @@ -2,9 +2,17 @@ |
2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
3 | package="com.example.user.firebaseauthdemo"> | 3 | package="com.example.user.firebaseauthdemo"> |
4 | 4 | ||
5 | - <user-permission android:name="android.permission.INTERNET" /> | 5 | + <user-permission android:name="android.permission.INTERNET"/> |
6 | - <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | 6 | + |
7 | - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | 7 | + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> |
8 | + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
9 | + | ||
10 | + <!-- | ||
11 | + The ACCESS_COARSE/FINE_LOCATION permissions are not required to use | ||
12 | + Google Maps Android API v2, but you must specify either coarse or fine | ||
13 | + location permissions for the 'MyLocation' functionality. | ||
14 | + --> | ||
15 | + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> | ||
8 | 16 | ||
9 | <application | 17 | <application |
10 | android:allowBackup="true" | 18 | android:allowBackup="true" |
... | @@ -15,18 +23,34 @@ | ... | @@ -15,18 +23,34 @@ |
15 | android:theme="@style/AppTheme"> | 23 | android:theme="@style/AppTheme"> |
16 | <activity android:name=".MainActivity"> | 24 | <activity android:name=".MainActivity"> |
17 | <intent-filter> | 25 | <intent-filter> |
18 | - <action android:name="android.intent.action.MAIN" /> | 26 | + <action android:name="android.intent.action.MAIN"/> |
19 | 27 | ||
20 | - <category android:name="android.intent.category.LAUNCHER" /> | 28 | + <category android:name="android.intent.category.LAUNCHER"/> |
21 | </intent-filter> | 29 | </intent-filter> |
22 | </activity> | 30 | </activity> |
23 | - <activity android:name=".LoginActivity" /> | 31 | + <activity android:name=".LoginActivity"/> |
24 | - <activity android:name=".ProfileActivity" /> | 32 | + <activity android:name=".ProfileActivity"/> |
25 | <activity | 33 | <activity |
26 | android:name=".Main2Activity" | 34 | android:name=".Main2Activity" |
27 | android:label="@string/title_activity_main2" | 35 | android:label="@string/title_activity_main2" |
28 | - android:theme="@style/AppTheme.NoActionBar" /> | 36 | + android:theme="@style/AppTheme.NoActionBar"/> |
29 | - <activity android:name=".PostActivity"></activity> | 37 | + <activity android:name=".PostActivity"/> |
38 | + <!-- | ||
39 | + The API key for Google Maps-based APIs is defined as a string resource. | ||
40 | + (See the file "res/values/google_maps_api.xml"). | ||
41 | + Note that the API key is linked to the encryption key used to sign the APK. | ||
42 | + You need a different API key for each encryption key, including the release key that is used to | ||
43 | + sign the APK for publishing. | ||
44 | + You can define the keys for the debug and release targets in src/debug/ and src/release/. | ||
45 | + --> | ||
46 | + <meta-data | ||
47 | + android:name="com.google.android.geo.API_KEY" | ||
48 | + android:value="@string/google_maps_key"/> | ||
49 | + | ||
50 | + <activity | ||
51 | + android:name=".MapsActivity" | ||
52 | + android:label="@string/title_activity_maps"> | ||
53 | + </activity> | ||
30 | </application> | 54 | </application> |
31 | 55 | ||
32 | </manifest> | 56 | </manifest> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -7,22 +7,101 @@ import android.view.LayoutInflater; | ... | @@ -7,22 +7,101 @@ import android.view.LayoutInflater; |
7 | import android.view.View; | 7 | import android.view.View; |
8 | import android.view.ViewGroup; | 8 | import android.view.ViewGroup; |
9 | 9 | ||
10 | +import com.google.android.gms.maps.CameraUpdateFactory; | ||
11 | +import com.google.android.gms.maps.GoogleMap; | ||
12 | +import com.google.android.gms.maps.MapView; | ||
13 | +import com.google.android.gms.maps.OnMapReadyCallback; | ||
14 | +import com.google.android.gms.maps.model.LatLng; | ||
15 | +import com.google.android.gms.maps.model.MarkerOptions; | ||
16 | + | ||
10 | /** | 17 | /** |
11 | * Created by HYB on 2017. 10. 11.. | 18 | * Created by HYB on 2017. 10. 11.. |
12 | */ | 19 | */ |
13 | 20 | ||
14 | -public class Map extends Fragment { | 21 | +public class Map extends Fragment implements OnMapReadyCallback |
22 | +{ | ||
23 | + private MapView mapView = null; | ||
24 | + | ||
25 | + @Override | ||
26 | + public void onCreate(@Nullable Bundle savedInstanceState) { | ||
27 | + super.onCreate(savedInstanceState); | ||
28 | + } | ||
15 | 29 | ||
16 | @Nullable | 30 | @Nullable |
17 | @Override | 31 | @Override |
18 | - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { | 32 | + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
19 | - return inflater.inflate(R.layout.map, container, false); | 33 | + View layout = inflater.inflate(R.layout.map, container, false); |
34 | + | ||
35 | + mapView = (MapView)layout.findViewById(R.id.mapView); | ||
36 | + mapView.getMapAsync(this); | ||
37 | + | ||
38 | + return layout; | ||
20 | } | 39 | } |
21 | 40 | ||
22 | @Override | 41 | @Override |
23 | - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | 42 | + public void onStart() { |
24 | - super.onViewCreated(view, savedInstanceState); | 43 | + super.onStart(); |
44 | + mapView.onStart(); | ||
45 | + } | ||
25 | 46 | ||
26 | - getActivity().setTitle("Map"); | 47 | + @Override |
48 | + public void onStop() { | ||
49 | + super.onStop(); | ||
50 | + mapView.onStop(); | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public void onSaveInstanceState(Bundle outState) { | ||
55 | + super.onSaveInstanceState(outState); | ||
56 | + mapView.onSaveInstanceState(outState); | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public void onResume() { | ||
61 | + super.onResume(); | ||
62 | + mapView.onResume(); | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + public void onPause() { | ||
67 | + super.onPause(); | ||
68 | + mapView.onPause(); | ||
27 | } | 69 | } |
70 | + | ||
71 | + @Override | ||
72 | + public void onLowMemory() { | ||
73 | + super.onLowMemory(); | ||
74 | + mapView.onLowMemory(); | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public void onDestroy() { | ||
79 | + super.onDestroy(); | ||
80 | + mapView.onLowMemory(); | ||
81 | + } | ||
82 | + | ||
83 | + @Override | ||
84 | + public void onActivityCreated(@Nullable Bundle savedInstanceState) { | ||
85 | + super.onActivityCreated(savedInstanceState); | ||
86 | + | ||
87 | + //액티비티가 처음 생성될 때 실행되는 함수 | ||
88 | + | ||
89 | + if(mapView != null) | ||
90 | + { | ||
91 | + mapView.onCreate(savedInstanceState); | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
95 | + @Override | ||
96 | + public void onMapReady(GoogleMap googleMap) { | ||
97 | + LatLng SEOUL = new LatLng(37.56, 126.97); | ||
98 | + MarkerOptions markerOptions = new MarkerOptions(); | ||
99 | + markerOptions.position(SEOUL); | ||
100 | + markerOptions.title("서울"); | ||
101 | + markerOptions.snippet("수도"); | ||
102 | + googleMap.addMarker(markerOptions); | ||
103 | + googleMap.moveCamera(CameraUpdateFactory.newLatLng(SEOUL)); | ||
104 | + googleMap.animateCamera(CameraUpdateFactory.zoomTo(13)); | ||
105 | + } | ||
106 | + | ||
28 | } | 107 | } | ... | ... |
... | @@ -10,4 +10,9 @@ | ... | @@ -10,4 +10,9 @@ |
10 | android:text="Terror inform is displayed in here." | 10 | android:text="Terror inform is displayed in here." |
11 | android:textAppearance="@style/TextAppearance.AppCompat.Headline" /> | 11 | android:textAppearance="@style/TextAppearance.AppCompat.Headline" /> |
12 | 12 | ||
13 | + <com.google.android.gms.maps.MapView | ||
14 | + android:id="@+id/mapView" | ||
15 | + android:layout_width="match_parent" | ||
16 | + android:layout_height="match_parent"/> | ||
17 | + | ||
13 | </LinearLayout> | 18 | </LinearLayout> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -6,4 +6,5 @@ | ... | @@ -6,4 +6,5 @@ |
6 | <string name="navigation_drawer_close">Close navigation drawer</string> | 6 | <string name="navigation_drawer_close">Close navigation drawer</string> |
7 | 7 | ||
8 | <string name="action_settings">Settings</string> | 8 | <string name="action_settings">Settings</string> |
9 | + <string name="title_activity_maps">Map</string> | ||
9 | </resources> | 10 | </resources> | ... | ... |
1 | +<resources> | ||
2 | + <!-- | ||
3 | + TODO: Before you release your application, you need a Google Maps API key. | ||
4 | + | ||
5 | + To do this, you can either add your release key credentials to your existing | ||
6 | + key, or create a new key. | ||
7 | + | ||
8 | + Note that this file specifies the API key for the release build target. | ||
9 | + If you have previously set up a key for the debug target with the debug signing certificate, | ||
10 | + you will also need to set up a key for your release certificate. | ||
11 | + | ||
12 | + Follow the directions here: | ||
13 | + | ||
14 | + https://developers.google.com/maps/documentation/android/signup | ||
15 | + | ||
16 | + Once you have your key (it starts with "AIza"), replace the "google_maps_key" | ||
17 | + string in this file. | ||
18 | + --> | ||
19 | + <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false"> | ||
20 | + YOUR_KEY_HERE | ||
21 | + </string> | ||
22 | +</resources> |
-
Please register or login to post a comment