diff --git a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/DemoDetailsList.kt b/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/DemoDetailsList.kt index 65ba6b9f..e740683d 100644 --- a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/DemoDetailsList.kt +++ b/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/DemoDetailsList.kt @@ -57,6 +57,10 @@ class DemoDetailsList { PolygonDemoActivity::class.java), DemoDetails(R.string.polyline_demo_label, R.string.polyline_demo_description, PolylineDemoActivity::class.java), + DemoDetails( + R.string.raw_map_view_demo_label, + R.string.raw_map_view_demo_description, + RawMapViewDemoActivity::class.java), DemoDetails( R.string.street_view_panorama_basic_demo_label, R.string.street_view_panorama_basic_demo_details, diff --git a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/RawMapViewDemoActivity.kt b/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/RawMapViewDemoActivity.kt new file mode 100644 index 00000000..f15075f2 --- /dev/null +++ b/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/RawMapViewDemoActivity.kt @@ -0,0 +1,89 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.example.kotlindemos + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.google.android.gms.maps.GoogleMap +import com.google.android.gms.maps.MapView +import com.google.android.gms.maps.OnMapReadyCallback +import com.google.android.gms.maps.model.LatLng +import com.google.android.gms.maps.model.MarkerOptions + +/** + * This shows how to create a simple activity with a raw MapView and add a marker to it. This + * requires forwarding all the important lifecycle methods onto MapView. + */ +class RawMapViewDemoActivity : AppCompatActivity(), OnMapReadyCallback { + private lateinit var mapView: MapView + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.raw_mapview_demo) + + // *** IMPORTANT *** + // MapView requires that the Bundle you pass contain _ONLY_ MapView SDK + // objects or sub-Bundles. + val mapViewBundle = savedInstanceState?.getBundle(MAPVIEW_BUNDLE_KEY) + mapView = findViewById(R.id.map) + mapView.onCreate(mapViewBundle) + mapView.getMapAsync(this) + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + val mapViewBundle = outState.getBundle(MAPVIEW_BUNDLE_KEY) ?: Bundle().apply { + putBundle(MAPVIEW_BUNDLE_KEY, this) + } + mapView.onSaveInstanceState(mapViewBundle) + } + + override fun onResume() { + super.onResume() + mapView.onResume() + } + + override fun onStart() { + super.onStart() + mapView.onStart() + } + + override fun onStop() { + super.onStop() + mapView.onStop() + } + + override fun onMapReady(map: GoogleMap) { + map.addMarker(MarkerOptions().position(LatLng(0.0, 0.0)).title("Marker")) + } + + override fun onPause() { + mapView.onPause() + super.onPause() + } + + override fun onDestroy() { + mapView.onDestroy() + super.onDestroy() + } + + override fun onLowMemory() { + super.onLowMemory() + mapView.onLowMemory() + } + + companion object { + private const val MAPVIEW_BUNDLE_KEY = "MapViewBundleKey" + } +} \ No newline at end of file diff --git a/ApiDemos/kotlin/app/src/gms/res/layout/raw_mapview_demo.xml b/ApiDemos/kotlin/app/src/gms/res/layout/raw_mapview_demo.xml new file mode 100644 index 00000000..95b881d4 --- /dev/null +++ b/ApiDemos/kotlin/app/src/gms/res/layout/raw_mapview_demo.xml @@ -0,0 +1,19 @@ + + diff --git a/ApiDemos/kotlin/app/src/main/AndroidManifest.xml b/ApiDemos/kotlin/app/src/main/AndroidManifest.xml index 21b6a9d4..6080e675 100644 --- a/ApiDemos/kotlin/app/src/main/AndroidManifest.xml +++ b/ApiDemos/kotlin/app/src/main/AndroidManifest.xml @@ -57,6 +57,7 @@ + diff --git a/ApiDemos/kotlin/app/src/main/res/values/strings.xml b/ApiDemos/kotlin/app/src/main/res/values/strings.xml index 806fb352..c15422eb 100644 --- a/ApiDemos/kotlin/app/src/main/res/values/strings.xml +++ b/ApiDemos/kotlin/app/src/main/res/values/strings.xml @@ -234,6 +234,10 @@ Cloud Styling Demonstrates how to use a simple map using Cloud Styling. + + Raw MapView + Demonstrates how to use a raw MapView. + Alpha Butt diff --git a/ApiDemos/kotlin/app/src/v3/java/com/example/kotlindemos/DemoDetailsList.kt b/ApiDemos/kotlin/app/src/v3/java/com/example/kotlindemos/DemoDetailsList.kt index 47f6806f..f3bb5a62 100644 --- a/ApiDemos/kotlin/app/src/v3/java/com/example/kotlindemos/DemoDetailsList.kt +++ b/ApiDemos/kotlin/app/src/v3/java/com/example/kotlindemos/DemoDetailsList.kt @@ -23,7 +23,7 @@ package com.example.kotlindemos -import com.example.kotlindemos.polyline.PolylineDemoActivity; +import com.example.kotlindemos.polyline.PolylineDemoActivity /** * A list of all the demos we have available. @@ -31,40 +31,83 @@ import com.example.kotlindemos.polyline.PolylineDemoActivity; class DemoDetailsList { companion object { val DEMOS = listOf( - DemoDetails(R.string.basic_demo_label, R.string.basic_demo_details, + DemoDetails(R.string.basic_demo_label, R.string.basic_demo_details, BasicMapDemoActivity::class.java), - DemoDetails(R.string.camera_demo_label, R.string.camera_demo_description, + DemoDetails(R.string.camera_demo_label, R.string.camera_demo_description, CameraDemoActivity::class.java), - DemoDetails(R.string.circle_demo_label, R.string.circle_demo_details, + DemoDetails(R.string.circle_demo_label, R.string.circle_demo_details, CircleDemoActivity::class.java), - DemoDetails(R.string.close_info_window_demo_label, + DemoDetails(R.string.close_info_window_demo_label, R.string.close_info_window_demo_details, CloseInfoWindowDemoActivity::class.java), - DemoDetails(R.string.cloud_styling_label, - R.string.cloud_styling_description, - CloudBasedMapStylingDemoActivity::class.java), - DemoDetails(R.string.layers_demo_label, R.string.layers_demo_description, + DemoDetails( + R.string.events_demo_label, + R.string.events_demo_details, + EventsDemoActivity::class.java), + DemoDetails( + R.string.ground_overlay_demo_label, + R.string.ground_overlay_demo_details, + GroundOverlayDemoActivity::class.java), + DemoDetails(R.string.indoor_demo_label, R.string.indoor_demo_details, + IndoorDemoActivity::class.java), + DemoDetails(R.string.layers_demo_label, R.string.layers_demo_description, LayersDemoActivity::class.java), - DemoDetails(R.string.lite_list_demo_label, R.string.lite_list_demo_details, + DemoDetails(R.string.lite_demo_label, R.string.lite_demo_details, + LiteDemoActivity::class.java), + DemoDetails(R.string.lite_list_demo_label, R.string.lite_list_demo_details, LiteListDemoActivity::class.java), - DemoDetails(R.string.marker_collision_label, - R.string.marker_collision_description, - MarkerCollisionDemoActivity::class.java), - DemoDetails(R.string.markers_demo_label, R.string.markers_demo_description, + DemoDetails(R.string.markers_demo_label, R.string.markers_demo_description, MarkerDemoActivity::class.java), - DemoDetails(R.string.polygon_demo_label, R.string.polygon_demo_details, + DemoDetails(R.string.my_location_demo_label, R.string.my_location_demo_details, + MyLocationDemoActivity::class.java), + DemoDetails(R.string.polygon_demo_label, R.string.polygon_demo_details, PolygonDemoActivity::class.java), - DemoDetails(R.string.polyline_demo_label, R.string.polyline_demo_description, - PolylineDemoActivity::class.java), - DemoDetails( + DemoDetails(R.string.polyline_demo_label, R.string.polyline_demo_description, + PolylineDemoActivity::class.java), + DemoDetails( + R.string.raw_map_view_demo_label, + R.string.raw_map_view_demo_description, + RawMapViewDemoActivity::class.java), + DemoDetails( + R.string.street_view_panorama_basic_demo_label, + R.string.street_view_panorama_basic_demo_details, + StreetViewPanoramaBasicDemoActivity::class.java), + DemoDetails( R.string.street_view_panorama_navigation_demo_label, R.string.street_view_panorama_navigation_demo_details, StreetViewPanoramaNavigationDemoActivity::class.java), - DemoDetails(R.string.tags_demo_label, R.string.tags_demo_details, + DemoDetails( + R.string.split_street_view_panorama_and_map_demo_label, + R.string.split_street_view_panorama_and_map_demo_details, + SplitStreetViewPanoramaAndMapDemoActivity::class.java), + DemoDetails( + R.string.street_view_panorama_options_demo_label, + R.string.street_view_panorama_options_demo_details, + StreetViewPanoramaOptionsDemoActivity::class.java), + DemoDetails( + R.string.street_view_panorama_events_demo_label, + R.string.street_view_panorama_events_demo_details, + StreetViewPanoramaEventsDemoActivity::class.java), + DemoDetails( + R.string.street_view_panorama_view_demo_label, + R.string.street_view_panorama_view_demo_details, + StreetViewPanoramaViewDemoActivity::class.java + ), + DemoDetails(R.string.tags_demo_label, R.string.tags_demo_details, TagsDemoActivity::class.java), - DemoDetails(R.string.ui_settings_demo_label, R.string.ui_settings_demo_details, + DemoDetails( + R.string.tile_coordinate_demo_label, + R.string.tile_coordinate_demo_description, + TileCoordinateDemoActivity::class.java + ), + DemoDetails( + R.string.tile_overlay_demo_label, + R.string.tile_overlay_demo_description, + TileOverlayDemoActivity::class.java + ), + DemoDetails(R.string.ui_settings_demo_label, R.string.ui_settings_demo_details, UiSettingsDemoActivity::class.java), - DemoDetails(R.string.region_demo_label, R.string.region_demo_details, + DemoDetails(R.string.region_demo_label, R.string.region_demo_details, VisibleRegionDemoActivity::class.java) ) } diff --git a/ApiDemos/kotlin/app/src/v3/java/com/example/kotlindemos/RawMapViewDemoActivity.kt b/ApiDemos/kotlin/app/src/v3/java/com/example/kotlindemos/RawMapViewDemoActivity.kt new file mode 100644 index 00000000..5d7d7d64 --- /dev/null +++ b/ApiDemos/kotlin/app/src/v3/java/com/example/kotlindemos/RawMapViewDemoActivity.kt @@ -0,0 +1,96 @@ +/** + * DO NOT EDIT THIS FILE. + * + * This source code was autogenerated from source code within the `app/src/gms` directory + * and is not intended for modifications. If any edits should be made, please do so in the + * corresponding file under the `app/src/gms` directory. + */ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.example.kotlindemos + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.google.android.libraries.maps.GoogleMap +import com.google.android.libraries.maps.MapView +import com.google.android.libraries.maps.OnMapReadyCallback +import com.google.android.libraries.maps.model.LatLng +import com.google.android.libraries.maps.model.MarkerOptions + +/** + * This shows how to create a simple activity with a raw MapView and add a marker to it. This + * requires forwarding all the important lifecycle methods onto MapView. + */ +class RawMapViewDemoActivity : AppCompatActivity(), OnMapReadyCallback { + private lateinit var mapView: MapView + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.raw_mapview_demo) + + // *** IMPORTANT *** + // MapView requires that the Bundle you pass contain _ONLY_ MapView SDK + // objects or sub-Bundles. + val mapViewBundle = savedInstanceState?.getBundle(MAPVIEW_BUNDLE_KEY) + mapView = findViewById(R.id.map) + mapView.onCreate(mapViewBundle) + mapView.getMapAsync(this) + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + val mapViewBundle = outState.getBundle(MAPVIEW_BUNDLE_KEY) ?: Bundle().apply { + putBundle(MAPVIEW_BUNDLE_KEY, this) + } + mapView.onSaveInstanceState(mapViewBundle) + } + + override fun onResume() { + super.onResume() + mapView.onResume() + } + + override fun onStart() { + super.onStart() + mapView.onStart() + } + + override fun onStop() { + super.onStop() + mapView.onStop() + } + + override fun onMapReady(map: GoogleMap) { + map.addMarker(MarkerOptions().position(LatLng(0.0, 0.0)).title("Marker")) + } + + override fun onPause() { + mapView.onPause() + super.onPause() + } + + override fun onDestroy() { + mapView.onDestroy() + super.onDestroy() + } + + override fun onLowMemory() { + super.onLowMemory() + mapView.onLowMemory() + } + + companion object { + private const val MAPVIEW_BUNDLE_KEY = "MapViewBundleKey" + } +} \ No newline at end of file diff --git a/ApiDemos/kotlin/app/src/v3/java/com/example/kotlindemos/TileCoordinateDemoActivity.kt b/ApiDemos/kotlin/app/src/v3/java/com/example/kotlindemos/TileCoordinateDemoActivity.kt index dcaaac78..3e110d4a 100644 --- a/ApiDemos/kotlin/app/src/v3/java/com/example/kotlindemos/TileCoordinateDemoActivity.kt +++ b/ApiDemos/kotlin/app/src/v3/java/com/example/kotlindemos/TileCoordinateDemoActivity.kt @@ -20,7 +20,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.example.kotlindemos import android.content.Context diff --git a/ApiDemos/kotlin/app/src/v3/res/layout/raw_mapview_demo.xml b/ApiDemos/kotlin/app/src/v3/res/layout/raw_mapview_demo.xml new file mode 100644 index 00000000..6af0bbde --- /dev/null +++ b/ApiDemos/kotlin/app/src/v3/res/layout/raw_mapview_demo.xml @@ -0,0 +1,19 @@ + +