-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
37 changed files
with
908 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...s/java/app/src/gms/java/com/example/mapdemo/BackgroundColorCustomizationDemoActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...rc/gms/java/com/example/mapdemo/BackgroundColorCustomizationProgrammaticDemoActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.