mirror of
https://github.com/googlemaps/android-samples.git
synced 2025-12-08 18:02:20 +00:00
feat: adding styled map sample (#1433)
This commit is contained in:
parent
596b127a7c
commit
49c4502f1b
@ -1,18 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright (C) 2016 The Android Open Source Project
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2023 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
|
||||
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
|
||||
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.
|
||||
-->
|
||||
|
||||
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.
|
||||
--><!-- This can go anywhere in your layout (see other demos for some examples). -->
|
||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -1,18 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright (C) 2016 The Android Open Source Project
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2018 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
|
||||
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
|
||||
https://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.
|
||||
-->
|
||||
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.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
|
||||
@ -63,6 +63,7 @@
|
||||
<activity android:name=".StreetViewPanoramaNavigationDemoActivity" />
|
||||
<activity android:name=".StreetViewPanoramaOptionsDemoActivity" />
|
||||
<activity android:name=".StreetViewPanoramaViewDemoActivity" />
|
||||
<activity android:name=".StyledMapDemoActivity" />
|
||||
<activity android:name=".TagsDemoActivity" />
|
||||
<activity android:name=".TileCoordinateDemoActivity" />
|
||||
<activity android:name=".TileOverlayDemoActivity" />
|
||||
|
||||
@ -22,117 +22,120 @@ import com.example.kotlindemos.polyline.PolylineDemoActivity
|
||||
* A list of all the demos we have available.
|
||||
*/
|
||||
class DemoDetailsList {
|
||||
companion object {
|
||||
val DEMOS = listOf(
|
||||
DemoDetails(R.string.basic_demo_label,
|
||||
R.string.basic_demo_details,
|
||||
BasicMapDemoActivity::class.java),
|
||||
DemoDetails(R.string.background_color_customization_demo_label,
|
||||
R.string.background_color_customization_demo_description,
|
||||
BackgroundColorCustomizationDemoActivity::class.java),
|
||||
DemoDetails(R.string.background_color_customization_programmatic_demo_label,
|
||||
R.string.background_color_customization_programmatic_demo_description,
|
||||
BackgroundColorCustomizationProgrammaticDemoActivity::class.java),
|
||||
DemoDetails(R.string.camera_demo_label,
|
||||
R.string.camera_demo_description,
|
||||
CameraDemoActivity::class.java),
|
||||
DemoDetails(R.string.camera_clamping_demo_label,
|
||||
R.string.camera_clamping_demo_description,
|
||||
CameraClampingDemoActivity::class.java),
|
||||
DemoDetails(R.string.circle_demo_label, R.string.circle_demo_details,
|
||||
CircleDemoActivity::class.java),
|
||||
DemoDetails(R.string.cloud_styling_label, R.string.cloud_styling_description,
|
||||
CloudBasedMapStylingDemoActivity::class.java),
|
||||
DemoDetails(R.string.close_info_window_demo_label,
|
||||
R.string.close_info_window_demo_details,
|
||||
MarkerCloseInfoWindowOnRetapDemoActivity::class.java),
|
||||
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_demo_label,
|
||||
R.string.lite_demo_details,
|
||||
LiteDemoActivity::class.java),
|
||||
DemoDetails(R.string.location_source_demo_label,
|
||||
R.string.location_source_demo_description,
|
||||
LocationSourceDemoActivity::class.java),
|
||||
DemoDetails(R.string.lite_list_demo_label,
|
||||
R.string.lite_list_demo_details,
|
||||
LiteListDemoActivity::class.java),
|
||||
DemoDetails(R.string.map_in_pager_demo_label,
|
||||
R.string.map_in_pager_demo_description,
|
||||
MapInPagerDemoActivity::class.java),
|
||||
DemoDetails(R.string.markers_demo_label,
|
||||
R.string.markers_demo_description,
|
||||
MarkerDemoActivity::class.java),
|
||||
DemoDetails(R.string.multi_map_demo_label,
|
||||
R.string.multi_map_demo_description,
|
||||
MultiMapDemoActivity::class.java),
|
||||
DemoDetails(R.string.my_location_demo_label,
|
||||
R.string.my_location_demo_details,
|
||||
MyLocationDemoActivity::class.java),
|
||||
DemoDetails(R.string.options_demo_label,
|
||||
R.string.options_demo_description,
|
||||
OptionsDemoActivity::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(R.string.programmatic_demo_label,
|
||||
R.string.programmatic_demo_description,
|
||||
ProgrammaticDemoActivity::class.java),
|
||||
DemoDetails(R.string.raw_map_view_demo_label,
|
||||
R.string.raw_map_view_demo_description,
|
||||
RawMapViewDemoActivity::class.java),
|
||||
DemoDetails(R.string.save_state_demo_label,
|
||||
R.string.save_state_demo_description,
|
||||
SaveStateDemoActivity::class.java),
|
||||
DemoDetails(R.string.snapshot_demo_label,
|
||||
R.string.snapshot_demo_description,
|
||||
SnapshotDemoActivity::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.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.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,
|
||||
VisibleRegionDemoActivity::class.java)
|
||||
)
|
||||
}
|
||||
companion object {
|
||||
val DEMOS = listOf(
|
||||
DemoDetails(R.string.basic_demo_label,
|
||||
R.string.basic_demo_details,
|
||||
BasicMapDemoActivity::class.java),
|
||||
DemoDetails(R.string.background_color_customization_demo_label,
|
||||
R.string.background_color_customization_demo_description,
|
||||
BackgroundColorCustomizationDemoActivity::class.java),
|
||||
DemoDetails(R.string.background_color_customization_programmatic_demo_label,
|
||||
R.string.background_color_customization_programmatic_demo_description,
|
||||
BackgroundColorCustomizationProgrammaticDemoActivity::class.java),
|
||||
DemoDetails(R.string.camera_demo_label,
|
||||
R.string.camera_demo_description,
|
||||
CameraDemoActivity::class.java),
|
||||
DemoDetails(R.string.camera_clamping_demo_label,
|
||||
R.string.camera_clamping_demo_description,
|
||||
CameraClampingDemoActivity::class.java),
|
||||
DemoDetails(R.string.circle_demo_label, R.string.circle_demo_details,
|
||||
CircleDemoActivity::class.java),
|
||||
DemoDetails(R.string.cloud_styling_label, R.string.cloud_styling_description,
|
||||
CloudBasedMapStylingDemoActivity::class.java),
|
||||
DemoDetails(R.string.close_info_window_demo_label,
|
||||
R.string.close_info_window_demo_details,
|
||||
MarkerCloseInfoWindowOnRetapDemoActivity::class.java),
|
||||
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_demo_label,
|
||||
R.string.lite_demo_details,
|
||||
LiteDemoActivity::class.java),
|
||||
DemoDetails(R.string.location_source_demo_label,
|
||||
R.string.location_source_demo_description,
|
||||
LocationSourceDemoActivity::class.java),
|
||||
DemoDetails(R.string.lite_list_demo_label,
|
||||
R.string.lite_list_demo_details,
|
||||
LiteListDemoActivity::class.java),
|
||||
DemoDetails(R.string.map_in_pager_demo_label,
|
||||
R.string.map_in_pager_demo_description,
|
||||
MapInPagerDemoActivity::class.java),
|
||||
DemoDetails(R.string.markers_demo_label,
|
||||
R.string.markers_demo_description,
|
||||
MarkerDemoActivity::class.java),
|
||||
DemoDetails(R.string.multi_map_demo_label,
|
||||
R.string.multi_map_demo_description,
|
||||
MultiMapDemoActivity::class.java),
|
||||
DemoDetails(R.string.my_location_demo_label,
|
||||
R.string.my_location_demo_details,
|
||||
MyLocationDemoActivity::class.java),
|
||||
DemoDetails(R.string.options_demo_label,
|
||||
R.string.options_demo_description,
|
||||
OptionsDemoActivity::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(R.string.programmatic_demo_label,
|
||||
R.string.programmatic_demo_description,
|
||||
ProgrammaticDemoActivity::class.java),
|
||||
DemoDetails(R.string.raw_map_view_demo_label,
|
||||
R.string.raw_map_view_demo_description,
|
||||
RawMapViewDemoActivity::class.java),
|
||||
DemoDetails(R.string.save_state_demo_label,
|
||||
R.string.save_state_demo_description,
|
||||
SaveStateDemoActivity::class.java),
|
||||
DemoDetails(R.string.snapshot_demo_label,
|
||||
R.string.snapshot_demo_description,
|
||||
SnapshotDemoActivity::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.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.styled_map_demo_label,
|
||||
R.string.styled_map_demo_description,
|
||||
StyledMapDemoActivity::class.java),
|
||||
DemoDetails(R.string.tags_demo_label,
|
||||
R.string.tags_demo_details,
|
||||
TagsDemoActivity::class.java),
|
||||
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,
|
||||
VisibleRegionDemoActivity::class.java)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright 2023 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.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
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.MapStyleOptions
|
||||
import java.util.ArrayList
|
||||
|
||||
class StyledMapDemoActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
private var mMap: GoogleMap? = null
|
||||
private var mSelectedStyleId = R.string.style_label_default
|
||||
|
||||
companion object {
|
||||
private const val TAG = "StyledMapDemoActivity"
|
||||
private const val SELECTED_STYLE = "selected_style"
|
||||
private val SYDNEY = LatLng(-33.8688, 151.2093)
|
||||
}
|
||||
|
||||
private val mStyleIds = intArrayOf(
|
||||
R.string.style_label_retro,
|
||||
R.string.style_label_night,
|
||||
R.string.style_label_grayscale,
|
||||
R.string.style_label_no_pois_no_transit,
|
||||
R.string.style_label_default
|
||||
)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
if (savedInstanceState != null) {
|
||||
mSelectedStyleId = savedInstanceState.getInt(SELECTED_STYLE)
|
||||
}
|
||||
setContentView(R.layout.styled_map_demo)
|
||||
|
||||
val mapFragment =
|
||||
supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
|
||||
mapFragment.getMapAsync(this)
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
outState.putInt(SELECTED_STYLE, mSelectedStyleId)
|
||||
super.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onMapReady(map: GoogleMap) {
|
||||
mMap = map
|
||||
mMap?.moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY, 14f))
|
||||
setSelectedStyle()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.styled_map, menu)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == R.id.menu_style_choose) {
|
||||
showStylesDialog()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun showStylesDialog() {
|
||||
val styleNames = ArrayList<String>()
|
||||
for (style in mStyleIds) {
|
||||
styleNames.add(getString(style))
|
||||
}
|
||||
|
||||
val builder = AlertDialog.Builder(this)
|
||||
builder.setTitle(getString(R.string.style_choose))
|
||||
builder.setItems(styleNames.toTypedArray<CharSequence>(),
|
||||
DialogInterface.OnClickListener { _, which ->
|
||||
mSelectedStyleId = mStyleIds[which]
|
||||
val msg = getString(R.string.style_set_to, getString(mSelectedStyleId))
|
||||
Toast.makeText(baseContext, msg, Toast.LENGTH_SHORT).show()
|
||||
Log.d(TAG, msg)
|
||||
setSelectedStyle()
|
||||
})
|
||||
builder.show()
|
||||
}
|
||||
|
||||
private fun setSelectedStyle() {
|
||||
val style: MapStyleOptions?
|
||||
val id = mSelectedStyleId
|
||||
style = when (id) {
|
||||
R.string.style_label_retro ->
|
||||
MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_retro)
|
||||
R.string.style_label_night ->
|
||||
MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_night)
|
||||
R.string.style_label_grayscale ->
|
||||
MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_grayscale)
|
||||
R.string.style_label_no_pois_no_transit ->
|
||||
MapStyleOptions(
|
||||
"[" +
|
||||
" {" +
|
||||
" \"featureType\":\"poi.business\"," +
|
||||
" \"elementType\":\"all\"," +
|
||||
" \"stylers\":[" +
|
||||
" {" +
|
||||
" \"visibility\":\"off\"" +
|
||||
" }" +
|
||||
" ]" +
|
||||
" }," +
|
||||
" {" +
|
||||
" \"featureType\":\"transit\"," +
|
||||
" \"elementType\":\"all\"," +
|
||||
" \"stylers\":[" +
|
||||
" {" +
|
||||
" \"visibility\":\"off\"" +
|
||||
" }" +
|
||||
" ]" +
|
||||
" }" +
|
||||
"]"
|
||||
)
|
||||
R.string.style_label_default -> null
|
||||
else -> return
|
||||
}
|
||||
mMap?.setMapStyle(style)
|
||||
}
|
||||
}
|
||||
22
ApiDemos/kotlin/app/src/main/res/layout/styled_map_demo.xml
Normal file
22
ApiDemos/kotlin/app/src/main/res/layout/styled_map_demo.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2023 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.
|
||||
-->
|
||||
|
||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
class="com.google.android.gms.maps.SupportMapFragment" />
|
||||
24
ApiDemos/kotlin/app/src/main/res/menu/styled_map.xml
Normal file
24
ApiDemos/kotlin/app/src/main/res/menu/styled_map.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2023 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.
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/menu_style_choose"
|
||||
android:title="@string/style_choose"
|
||||
app:showAsAction="always"/>
|
||||
</menu>
|
||||
101
ApiDemos/kotlin/app/src/main/res/raw/mapstyle_grayscale.json
Normal file
101
ApiDemos/kotlin/app/src/main/res/raw/mapstyle_grayscale.json
Normal file
@ -0,0 +1,101 @@
|
||||
[
|
||||
{
|
||||
"featureType": "all",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#f5f5f5"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "all",
|
||||
"elementType": "labels.icon",
|
||||
"stylers": [
|
||||
{
|
||||
"saturation": -100
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "all",
|
||||
"elementType": "labels.text",
|
||||
"stylers": [
|
||||
{
|
||||
"saturation": -100
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "poi",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#eeeeee"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "poi.park",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#e5e5e5"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#ffffff"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.highway",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#dadada"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.highway",
|
||||
"elementType": "labels.icon",
|
||||
"stylers": [
|
||||
{
|
||||
"lightness": 30
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "transit.line",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#e5e5e5"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "transit.station",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#eeeeee"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "water",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#c9c9c9"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
191
ApiDemos/kotlin/app/src/main/res/raw/mapstyle_night.json
Normal file
191
ApiDemos/kotlin/app/src/main/res/raw/mapstyle_night.json
Normal file
@ -0,0 +1,191 @@
|
||||
[
|
||||
{
|
||||
"featureType": "all",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#242f3e"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "all",
|
||||
"elementType": "labels.text.stroke",
|
||||
"stylers": [
|
||||
{
|
||||
"lightness": -80
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "administrative",
|
||||
"elementType": "labels.text.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#746855"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "administrative.locality",
|
||||
"elementType": "labels.text.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#d59563"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "poi",
|
||||
"elementType": "labels.text.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#d59563"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "poi.park",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#263c3f"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "poi.park",
|
||||
"elementType": "labels.text.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#6b9a76"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#2b3544"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road",
|
||||
"elementType": "labels.text.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#9ca5b3"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.arterial",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#38414e"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.arterial",
|
||||
"elementType": "geometry.stroke",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#212a37"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.highway",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#746855"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.highway",
|
||||
"elementType": "geometry.stroke",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#1f2835"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.highway",
|
||||
"elementType": "labels.text.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#f3d19c"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.local",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#38414e"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.local",
|
||||
"elementType": "geometry.stroke",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#212a37"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "transit",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#2f3948"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "transit.station",
|
||||
"elementType": "labels.text.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#d59563"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "water",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#17263c"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "water",
|
||||
"elementType": "labels.text.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#515c6d"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "water",
|
||||
"elementType": "labels.text.stroke",
|
||||
"stylers": [
|
||||
{
|
||||
"lightness": -20
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
191
ApiDemos/kotlin/app/src/main/res/raw/mapstyle_retro.json
Normal file
191
ApiDemos/kotlin/app/src/main/res/raw/mapstyle_retro.json
Normal file
@ -0,0 +1,191 @@
|
||||
[
|
||||
{
|
||||
"featureType": "all",
|
||||
"elementType": "labels.text.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#755f5d"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "administrative",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#d4ccb9"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "administrative.country",
|
||||
"elementType": "geometry.stroke",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#baafae"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "administrative.land_parcel",
|
||||
"elementType": "geometry.stroke",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#d4ccb9"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "landscape.man_made",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#ebe3cd"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "landscape.natural",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#ebe3cd"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "landscape.natural",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"lightness": -10
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "poi",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#d4ccb9"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "poi",
|
||||
"elementType": "labels.icon",
|
||||
"stylers": [
|
||||
{
|
||||
"hue": "#ff7f00"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "poi.park",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#9ba56f"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#f5f1e6"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road",
|
||||
"elementType": "geometry.stroke",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#dfd8c3"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.arterial",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#fdfcf8"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.arterial",
|
||||
"elementType": "geometry.stroke",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#e4e3df"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.highway",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#f2cb77"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.highway",
|
||||
"elementType": "geometry.stroke",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#ecb43d"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.highway.controlled_access",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#e98d58"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "road.highway.controlled_access",
|
||||
"elementType": "geometry.stroke",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#d27f4f"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "transit.line",
|
||||
"elementType": "geometry",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#d4ccb9"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "transit.station.airport",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#d4ccb9"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"featureType": "water",
|
||||
"elementType": "geometry.fill",
|
||||
"stylers": [
|
||||
{
|
||||
"color": "#b9d3c2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -336,4 +336,16 @@
|
||||
description="Text displayed below the Background Color Customization - Programmatic demo title.">Demonstrates how to programmatically set a custom background color to a map.</string>
|
||||
<string name="show_map_tiles">Show Map Tiles</string>
|
||||
|
||||
<!-- Styling -->
|
||||
<string name="styled_map_demo_label">Styled Map</string>
|
||||
<string name="styled_map_demo_description">Demonstrates how to style a map.</string>
|
||||
<string name="style_label_retro">Retro</string>
|
||||
<string name="style_label_night">Night</string>
|
||||
<string name="style_label_grayscale">Grayscale</string>
|
||||
<string name="style_label_no_pois_no_transit">No POIs or transit</string>
|
||||
<string name="style_label_default">Default</string>
|
||||
<string name="style_choose">Choose style</string>
|
||||
<string name="style_set_to">Style set to: %1$s</string>
|
||||
|
||||
|
||||
</resources>
|
||||
@ -1 +1 @@
|
||||
MAPS_API_KEY=STUB_API_KEY
|
||||
MAPS_API_KEY=STUB_API_KEY
|
||||
Loading…
x
Reference in New Issue
Block a user