chore: add region tags to 6 samples (#1552)

This commit is contained in:
Angela Yu 2024-04-25 11:10:15 -07:00 committed by GitHub
parent cf74be5bc2
commit fa63927d15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 42 additions and 7 deletions

View File

@ -35,6 +35,7 @@ import com.google.android.gms.maps.model.PinConfig;
* The following sample showcases how to create Advanced Markers, and use all their customization
* possibilities.
*/
// [START maps_android_sample_marker_advanced]
public class AdvancedMarkersDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
private static final LatLng SINGAPORE = new LatLng(1.3521, 103.8198);
@ -135,3 +136,4 @@ public class AdvancedMarkersDemoActivity extends AppCompatActivity implements On
Marker marker5 = map.addMarker(advancedMarkerOptions5);
}
}
// [END maps_android_sample_marker_advanced]

View File

@ -31,6 +31,7 @@ import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to listen to some {@link GoogleMap} events.
*/
// [START maps_android_sample_events]
public class EventsDemoActivity extends AppCompatActivity
implements OnMapClickListener, OnMapLongClickListener, OnCameraIdleListener,
OnMapReadyCallback {
@ -75,3 +76,4 @@ public class EventsDemoActivity extends AppCompatActivity
cameraTextView.setText(map.getCameraPosition().toString());
}
}
// [END maps_android_sample_events]

View File

@ -64,6 +64,7 @@ import java.util.Random;
/**
* This shows how to place markers on a map.
*/
// [START maps_android_sample_marker]
public class MarkerDemoActivity extends AppCompatActivity implements
OnMarkerClickListener,
OnInfoWindowClickListener,
@ -505,3 +506,4 @@ public class MarkerDemoActivity extends AppCompatActivity implements
}
}
// [END maps_android_sample_marker]

View File

@ -41,6 +41,7 @@ import android.widget.Toast;
* android.Manifest.permission#ACCESS_COARSE_LOCATION} are requested at run time. If either
* permission is not granted, the Activity is finished with an error message.
*/
// [START maps_android_sample_my_location]
public class MyLocationDemoActivity extends AppCompatActivity
implements
OnMyLocationButtonClickListener,
@ -158,3 +159,4 @@ public class MyLocationDemoActivity extends AppCompatActivity
}
}
// [END maps_android_sample_my_location]

View File

@ -47,6 +47,7 @@ import java.util.List;
/**
* This shows how to draw polygons on a map.
*/
// [START maps_android_sample_polygons]
public class PolygonDemoActivity extends AppCompatActivity
implements OnSeekBarChangeListener, OnItemSelectedListener, OnMapReadyCallback {
@ -89,7 +90,6 @@ public class PolygonDemoActivity extends AppCompatActivity
R.string.pattern_dotted,
R.string.pattern_mixed,
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -131,6 +131,7 @@ public class PolygonDemoActivity extends AppCompatActivity
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
// [START_EXCLUDE silent]
private String[] getResourceStrings(int[] resourceIds) {
String[] strings = new String[resourceIds.length];
@ -139,6 +140,7 @@ public class PolygonDemoActivity extends AppCompatActivity
}
return strings;
}
// [END_EXCLUDE]
@Override
public void onMapReady(GoogleMap map) {
@ -186,6 +188,7 @@ public class PolygonDemoActivity extends AppCompatActivity
});
}
// [START_EXCLUDE silent]
/**
* Creates a List of LatLngs that form a rectangle with the given dimensions.
*/
@ -286,4 +289,6 @@ public class PolygonDemoActivity extends AppCompatActivity
mutablePolygon.setClickable(((CheckBox) view).isChecked());
}
}
}
// [END_EXCLUDE]
}
// [END maps_android_sample_polygons]

View File

@ -54,6 +54,7 @@ import java.util.List;
/**
* This shows how to draw polylines on a map.
*/
// [START maps_android_sample_polylines]
public class PolylineDemoActivity extends AppCompatActivity
implements OnSeekBarChangeListener, OnItemSelectedListener, OnMapReadyCallback {
@ -160,6 +161,7 @@ public class PolylineDemoActivity extends AppCompatActivity
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
// [START_EXCLUDE silent]
private String[] getResourceStrings(int[] resourceIds) {
String[] strings = new String[resourceIds.length];
@ -168,6 +170,7 @@ public class PolylineDemoActivity extends AppCompatActivity
}
return strings;
}
// [END_EXCLUDE]
@Override
public void onMapReady(GoogleMap map) {
@ -219,6 +222,7 @@ public class PolylineDemoActivity extends AppCompatActivity
});
}
// [START_EXCLUDE silent]
private Cap getSelectedCap(int pos) {
int id = CAP_TYPE_NAME_RESOURCE_IDS[pos];
if (id == R.string.cap_butt) {
@ -319,4 +323,6 @@ public class PolylineDemoActivity extends AppCompatActivity
mutablePolyline.setClickable(((CheckBox) view).isChecked());
}
}
}
// [END_EXCLUDE]
}
// [END maps_android_sample_polylines]

View File

@ -46,6 +46,7 @@ private val TAG = AdvancedMarkersDemoActivity::class.java.name
* The following sample showcases how to create Advanced Markers, and use all their customization
* possibilities.
*/
// [START maps_android_sample_marker_advanced]
class AdvancedMarkersDemoActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -136,4 +137,5 @@ class AdvancedMarkersDemoActivity : AppCompatActivity(), OnMapReadyCallback {
val marker5: Marker? = map.addMarker(advancedMarkerOptions5)
}
}
}
// [END maps_android_sample_marker_advanced]

View File

@ -25,6 +25,7 @@ import com.google.android.gms.maps.model.LatLng
/**
* This shows how to listen to some [GoogleMap] events.
*/
// [START maps_android_sample_events]
class EventsDemoActivity : AppCompatActivity(), OnMapClickListener,
OnMapLongClickListener, OnCameraIdleListener, OnMapReadyCallback {
@ -58,7 +59,8 @@ class EventsDemoActivity : AppCompatActivity(), OnMapClickListener,
}
override fun onCameraIdle() {
if(!::map.isInitialized) return
if (!::map.isInitialized) return
cameraTextView.text = map.cameraPosition.toString()
}
}
}
// [END maps_android_sample_events]

View File

@ -61,6 +61,7 @@ import java.util.Random
/**
* This shows how to place markers on a map.
*/
// [START maps_android_sample_marker]
class MarkerDemoActivity :
AppCompatActivity(),
OnMarkerClickListener,
@ -478,6 +479,7 @@ class MarkerDemoActivity :
}
}
}
// [END maps_android_sample_marker]
/**
* This stores the details of a place that used to draw a marker

View File

@ -37,6 +37,7 @@ import com.google.android.gms.maps.SupportMapFragment
* Permission for [Manifest.permission.ACCESS_FINE_LOCATION] and [Manifest.permission.ACCESS_COARSE_LOCATION]
* are requested at run time. If either permission is not granted, the Activity is finished with an error message.
*/
// [START maps_android_sample_my_location]
class MyLocationDemoActivity : AppCompatActivity(),
OnMyLocationButtonClickListener,
OnMyLocationClickListener, OnMapReadyCallback,
@ -183,4 +184,5 @@ class MyLocationDemoActivity : AppCompatActivity(),
*/
private const val LOCATION_PERMISSION_REQUEST_CODE = 1
}
}
}
// [END maps_android_sample_my_location]

View File

@ -82,6 +82,7 @@ class PolygonDemoActivity :
private val patternTypeNameResourceIds = intArrayOf(R.string.pattern_solid, // Default
R.string.pattern_dashed, R.string.pattern_dotted, R.string.pattern_mixed)
// [START maps_android_sample_polygons]
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.polygon_demo)
@ -128,10 +129,12 @@ class PolygonDemoActivity :
val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
mapFragment.getMapAsync(this)
}
// [START_EXCLUDE silent]
private fun getResourceStrings(resourceIds: IntArray): List<String> {
return resourceIds.map { getString(it) }
}
// [END_EXCLUDE]
override fun onMapReady(googleMap: GoogleMap) {
@ -184,6 +187,7 @@ class PolygonDemoActivity :
}
}
// [END maps_android_sample_polygons]
/**
* Creates a List of LatLngs that form a rectangle with the given dimensions.

View File

@ -108,6 +108,7 @@ class PolylineDemoActivity :
R.string.pattern_dotted,
R.string.pattern_mixed)
// [START maps_android_sample_polylines]
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.polyline_demo)
@ -156,10 +157,12 @@ class PolylineDemoActivity :
val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
mapFragment.getMapAsync(this)
}
// [START_EXCLUDE silent]
private fun getResourceStrings(resourceIds: IntArray): List<String> {
return resourceIds.map { getString(it) }
}
// [END_EXCLUDE]
override fun onMapReady(googleMap: GoogleMap) {
googleMap
@ -215,6 +218,7 @@ class PolylineDemoActivity :
view -> mutablePolyline.isClickable = (view as CheckBox).isChecked
}
}
// [END maps_android_sample_polylines]
private fun getSelectedCap(pos: Int): Cap? {
return when (capTypeNameResourceIds[pos]) {