Skip to content

Commit

Permalink
feat: 18.0.0 samples (#732)
Browse files Browse the repository at this point in the history
* feat: 18.0.0 samples

* Map BG Color
* Moving cloud based map styling from v3 to gms
* Opt-in renderer

Change-Id: I094e53c9d9ef6b59abe443fb0791646b025cbd3d

* Add exported and bump minSdkVersion

Change-Id: Ied1e4e0aa507b3e67ce09679824225dd4fca88a3

* Bump snippet repo versions.

Change-Id: I50183bcfa4ef5a11d910545848200a9be03605c3

* Bump 18.0.0

Change-Id: I6c174f15e4afa4b2b20a52e956fc1c82e9f71d60
  • Loading branch information
arriolac committed Oct 27, 2021
1 parent ee36b47 commit cd44d81
Show file tree
Hide file tree
Showing 37 changed files with 908 additions and 202 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2021 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.

version: 2
updates:
- package-ecosystem: gradle
Expand Down
16 changes: 9 additions & 7 deletions ApiDemos/java/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ plugins {
}

android {
compileSdkVersion 30
compileSdkVersion 31

defaultConfig {
applicationId "com.example.mapdemo"
minSdkVersion 16
targetSdkVersion 30
minSdkVersion 19
targetSdkVersion 31
versionCode 1
versionName "1.0"
multiDexEnabled true
Expand All @@ -37,19 +37,19 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation 'com.android.volley:volley:1.2.1'

// GMS
gmsImplementation 'com.google.android.gms:play-services-maps:17.0.1'
gmsImplementation 'com.google.android.gms:play-services-maps:18.0.0'

// V3
v3Implementation 'com.google.android.libraries.maps:maps:3.1.0-beta'
Expand All @@ -60,6 +60,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

// Deprecated
task generateV3(type: Copy) {
group "V3 Beta"
description "Copies source code from GMS to V3 BETA."
Expand All @@ -72,6 +73,7 @@ task generateV3(type: Copy) {
filter(ConcatFilter, prepend: file('../../V3_FILE_HEADER'))
}

// Deprecated
task generateV3Layout(type: Copy) {
group "V3 Beta"
description "Copies layout files from GMS to V3 BETA."
Expand Down
9 changes: 8 additions & 1 deletion ApiDemos/java/app/src/gms/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -33,6 +34,12 @@
<activity
android:name=".BasicMapDemoActivity"
android:label="@string/basic_map_demo_label" />
<activity
android:name=".BackgroundColorCustomizationDemoActivity"
android:label="@string/background_color_customization_demo_label"/>
<activity
android:name=".BackgroundColorCustomizationProgrammaticDemoActivity"
android:label="@string/background_color_customization_programmatic_demo_label"/>
<activity
android:name=".CameraDemoActivity"
android:label="@string/camera_demo_label" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2021 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.mapdemo;

import android.os.Bundle;
import android.widget.CheckBox;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.common.internal.Preconditions;
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;

/**
* This shows how to create a simple activity with a custom background color appiled to the map, and
* add a marker on the map.
*/
public class BackgroundColorCustomizationDemoActivity extends AppCompatActivity
implements OnMapReadyCallback {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.background_color_customization_demo);

SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

Preconditions.checkNotNull(mapFragment)
.getMapAsync(this);
}

/**
* This is where we can add markers or lines, add listeners or move the camera. In this case, we
* just add a marker near Africa.
*/
@Override
public void onMapReady(GoogleMap map) {
map.setMapType(GoogleMap.MAP_TYPE_NONE);

CheckBox mapTypeToggleCheckbox = (CheckBox) findViewById(R.id.map_type_toggle);
mapTypeToggleCheckbox.setOnCheckedChangeListener(
(view, isChecked) -> map.setMapType(isChecked ? GoogleMap.MAP_TYPE_NORMAL : GoogleMap.MAP_TYPE_NONE));

map.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2021 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.mapdemo;

import android.graphics.Color;
import android.os.Bundle;
import android.widget.CheckBox;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentTransaction;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMapOptions;
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;

/**
* This shows how to to instantiate a SupportMapFragment programmatically with a custom background
* color applied to the map, and add a marker on the map.
*/
public class BackgroundColorCustomizationProgrammaticDemoActivity extends AppCompatActivity
implements OnMapReadyCallback {

private static final String MAP_FRAGMENT_TAG = "map";

private static final Integer LIGHT_PINK_COLOR = Color.argb(153, 240, 178, 221);

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.background_color_customization_programmatic_demo);

// It isn't possible to set a fragment's id programmatically so we set a tag instead and
// search for it using that.
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentByTag(MAP_FRAGMENT_TAG);

// We only create a fragment if it doesn't already exist.
if (mapFragment == null) {
// To programmatically add the map, we first create a SupportMapFragment, with the
// GoogleMapOptions to set the custom background color displayed before the map tiles load.
mapFragment =
SupportMapFragment.newInstance(new GoogleMapOptions().backgroundColor(LIGHT_PINK_COLOR));

// Then we add the fragment using a FragmentTransaction.
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.map, mapFragment, MAP_FRAGMENT_TAG);
fragmentTransaction.commit();
}
mapFragment.getMapAsync(this);
}

@Override
public void onMapReady(GoogleMap map) {
map.setMapType(GoogleMap.MAP_TYPE_NONE);

CheckBox mapTypeToggleCheckbox = (CheckBox) findViewById(R.id.map_type_toggle);
mapTypeToggleCheckbox.setOnCheckedChangeListener(
(view, isChecked) -> map.setMapType(isChecked ? GoogleMap.MAP_TYPE_NORMAL : GoogleMap.MAP_TYPE_NONE));

map.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@

package com.example.mapdemo;

import android.content.Intent;
import android.net.Uri;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnMarkerClickListener;
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.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import android.os.Bundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.libraries.maps.GoogleMap;
import com.google.android.libraries.maps.OnMapReadyCallback;
import com.google.android.libraries.maps.SupportMapFragment;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;

/**
* This shows how to use Cloud-based Map Styling in a simple Activity. For more information on how
Expand Down

0 comments on commit cd44d81

Please sign in to comment.