Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions ApiDemos/project/common-ui/src/main/res/layout/events_demo.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2025 Google LLC
Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,10 +37,12 @@
app:layout_constraintTop_toBottomOf="@+id/top_bar" />

<LinearLayout
android:id="@+id/events_info_panel"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_height="wrap_content"
android:background="?attr/colorSurface"
android:orientation="vertical"

android:padding="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/top_bar">
Expand All @@ -49,12 +51,15 @@
android:id="@+id/tap_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:text="@string/tap_instructions" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/camera_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:text="@string/move_the_camera" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
18 changes: 10 additions & 8 deletions ApiDemos/project/common-ui/src/main/res/layout/layers_demo.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2025 Google LLC
Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,38 +43,40 @@
android:id="@+id/checkbox_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white"
android:minWidth="160dp"
android:background="?attr/colorSurface"
android:orientation="vertical"
android:padding="6dp"
android:padding="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/map">

<Spinner
android:id="@+id/layers_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:minHeight="48dp" />

<CheckBox
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/traffic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/traffic" />

<CheckBox
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/my_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/my_location" />

<CheckBox
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/buildings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/buildings" />

<CheckBox
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/indoor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
123 changes: 68 additions & 55 deletions ApiDemos/project/common-ui/src/main/res/layout/marker_demo.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2025 Google LLC
Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/map_container"
android:layout_width="match_parent"
Expand All @@ -27,12 +27,59 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="@string/marker_demo_label" />
app:title="@string/marker_demo_label"
app:titleTextColor="?attr/colorOnPrimary" />

<LinearLayout
android:id="@+id/top_controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface"
android:orientation="vertical"
android:padding="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/top_bar">

<TextView
android:id="@+id/top_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="2"
android:text="@string/drag_melbourne" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<CheckBox
android:id="@+id/flat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/flat" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="@string/rotation" />

<SeekBar
android:id="@+id/rotationSeekBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/map_frame"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/top_controls">

<androidx.fragment.app.FragmentContainerView
android:id="@+id/map"
Expand All @@ -44,25 +91,28 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:background="@color/white"
android:background="?attr/colorSurface"
android:orientation="vertical"
android:padding="5dp">
android:padding="8dp">

<LinearLayout
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Button
android:id="@+id/clear_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/clear_map" />
<Button
android:id="@+id/clear_map"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/clear_map" />

<Button
android:id="@+id/reset_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/reset_map" />
<Button
android:id="@+id/reset_map"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/reset_map" />
</LinearLayout>

<RadioGroup
Expand Down Expand Up @@ -92,41 +142,4 @@
</LinearLayout>
</FrameLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
android:background="@color/white"
android:orientation="vertical">

<TextView
android:id="@+id/top_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="2"
android:text="@string/drag_melbourne" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<CheckBox
android:id="@+id/flat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/flat" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="@string/rotation" />

<SeekBar
android:id="@+id/rotationSeekBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@

import android.os.Bundle;
import android.widget.TextView;
import java.util.Locale;

import androidx.appcompat.app.AppCompatActivity;

Expand All @@ -34,7 +35,7 @@
// [START maps_android_sample_events]
public class EventsDemoActivity extends SamplesBaseActivity
implements OnMapClickListener, OnMapLongClickListener, OnCameraIdleListener,
OnMapReadyCallback {
GoogleMap.OnCameraMoveListener, OnMapReadyCallback {

private TextView tapTextView;
private TextView cameraTextView;
Expand All @@ -59,22 +60,51 @@ public void onMapReady(GoogleMap map) {
this.map = map;
this.map.setOnMapClickListener(this);
this.map.setOnMapLongClickListener(this);
this.map.setOnCameraMoveListener(this);
this.map.setOnCameraIdleListener(this);
updateCameraPosition();
}

@Override
public void onMapClick(LatLng point) {
tapTextView.setText("tapped, point=" + point);
String lat = String.format(Locale.US, "%.6f", point.latitude);
String lng = String.format(Locale.US, "%.6f", point.longitude);
tapTextView.setText(getString(com.example.common_ui.R.string.events_tapped_format, lat, lng));
}

@Override
public void onMapLongClick(LatLng point) {
tapTextView.setText("long pressed, point=" + point);
String lat = String.format(Locale.US, "%.6f", point.latitude);
String lng = String.format(Locale.US, "%.6f", point.longitude);
tapTextView.setText(getString(com.example.common_ui.R.string.events_long_pressed_format, lat, lng));
}

@Override
public void onCameraMove() {
updateCameraPosition();
}

@Override
public void onCameraIdle() {
cameraTextView.setText(map.getCameraPosition().toString());
updateCameraPosition();
}

private void updateCameraPosition() {
if (map == null) return;
com.google.android.gms.maps.model.CameraPosition pos = map.getCameraPosition();
String lat = String.format(Locale.US, "%.6f", pos.target.latitude);
String lng = String.format(Locale.US, "%.6f", pos.target.longitude);
String zoom = String.format(Locale.US, "%.1f", pos.zoom);
String tilt = String.format(Locale.US, "%.1f", pos.tilt);
String bearing = String.format(Locale.US, "%.1f", pos.bearing);
cameraTextView.setText(getString(
com.example.common_ui.R.string.events_camera_position_format,
lat,
lng,
zoom,
tilt,
bearing
));
}
}
// [END maps_android_sample_events]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -88,6 +88,15 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onMapReady(GoogleMap map) {
mMap = map;

com.google.android.gms.maps.model.CameraPosition initialPosition =
new com.google.android.gms.maps.model.CameraPosition.Builder()
.target(new com.google.android.gms.maps.model.LatLng(-33.8688, 151.2093))
.zoom(16.5f)
.tilt(40.0f)
.build();
mMap.moveCamera(com.google.android.gms.maps.CameraUpdateFactory.newCameraPosition(initialPosition));

updateMapType();
updateTraffic();
updateMyLocation();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -90,6 +90,11 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(com.example.common_ui.R.layout.basic_demo);

androidx.appcompat.widget.Toolbar toolbar = findViewById(com.example.common_ui.R.id.top_bar);
if (toolbar != null) {
toolbar.setTitle(com.example.common_ui.R.string.location_source_demo_label);
}

mLocationSource = new LongPressLocationSource();

SupportMapFragment mapFragment =
Expand Down
Loading