Skip to content

Commit

Permalink
chore: add region tags to 6 samples (#1552)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangela authored Apr 25, 2024
1 parent cf74be5 commit fa63927
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* 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);
Expand Down Expand Up @@ -135,3 +136,4 @@ public void onMapReady(GoogleMap map) {
Marker marker5 = map.addMarker(advancedMarkerOptions5);
}
}
// [END maps_android_sample_marker_advanced]
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
/**
* 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 {
Expand Down Expand Up @@ -75,3 +76,4 @@ public void onCameraIdle() {
cameraTextView.setText(map.getCameraPosition().toString());
}
}
// [END maps_android_sample_events]
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
/**
* This shows how to place markers on a map.
*/
// [START maps_android_sample_marker]
public class MarkerDemoActivity extends AppCompatActivity implements
OnMarkerClickListener,
OnInfoWindowClickListener,
Expand Down Expand Up @@ -505,3 +506,4 @@ public void onMarkerDrag(Marker marker) {
}

}
// [END maps_android_sample_marker]
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* 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,
Expand Down Expand Up @@ -158,3 +159,4 @@ private void showMissingPermissionError() {
}

}
// [END maps_android_sample_my_location]
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
/**
* This shows how to draw polygons on a map.
*/
// [START maps_android_sample_polygons]
public class PolygonDemoActivity extends AppCompatActivity
implements OnSeekBarChangeListener, OnItemSelectedListener, OnMapReadyCallback {

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -131,6 +131,7 @@ protected void onCreate(Bundle savedInstanceState) {
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
// [START_EXCLUDE silent]

private String[] getResourceStrings(int[] resourceIds) {
String[] strings = new String[resourceIds.length];
Expand All @@ -139,6 +140,7 @@ private String[] getResourceStrings(int[] resourceIds) {
}
return strings;
}
// [END_EXCLUDE]

@Override
public void onMapReady(GoogleMap map) {
Expand Down Expand Up @@ -186,6 +188,7 @@ public void onPolygonClick(Polygon polygon) {
});
}

// [START_EXCLUDE silent]
/**
* Creates a List of LatLngs that form a rectangle with the given dimensions.
*/
Expand Down Expand Up @@ -286,4 +289,6 @@ public void toggleClickability(View view) {
mutablePolygon.setClickable(((CheckBox) view).isChecked());
}
}
}
// [END_EXCLUDE]
}
// [END maps_android_sample_polygons]
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
/**
* This shows how to draw polylines on a map.
*/
// [START maps_android_sample_polylines]
public class PolylineDemoActivity extends AppCompatActivity
implements OnSeekBarChangeListener, OnItemSelectedListener, OnMapReadyCallback {

Expand Down Expand Up @@ -160,6 +161,7 @@ protected void onCreate(Bundle savedInstanceState) {
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
// [START_EXCLUDE silent]

private String[] getResourceStrings(int[] resourceIds) {
String[] strings = new String[resourceIds.length];
Expand All @@ -168,6 +170,7 @@ private String[] getResourceStrings(int[] resourceIds) {
}
return strings;
}
// [END_EXCLUDE]

@Override
public void onMapReady(GoogleMap map) {
Expand Down Expand Up @@ -219,6 +222,7 @@ public void onPolylineClick(Polyline polyline) {
});
}

// [START_EXCLUDE silent]
private Cap getSelectedCap(int pos) {
int id = CAP_TYPE_NAME_RESOURCE_IDS[pos];
if (id == R.string.cap_butt) {
Expand Down Expand Up @@ -319,4 +323,6 @@ public void toggleClickability(View view) {
mutablePolyline.setClickable(((CheckBox) view).isChecked());
}
}
}
// [END_EXCLUDE]
}
// [END maps_android_sample_polylines]
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -136,4 +137,5 @@ class AdvancedMarkersDemoActivity : AppCompatActivity(), OnMapReadyCallback {

val marker5: Marker? = map.addMarker(advancedMarkerOptions5)
}
}
}
// [END maps_android_sample_marker_advanced]
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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]
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -478,6 +479,7 @@ class MarkerDemoActivity :
}
}
}
// [END maps_android_sample_marker]

/**
* This stores the details of a place that used to draw a marker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -183,4 +184,5 @@ class MyLocationDemoActivity : AppCompatActivity(),
*/
private const val LOCATION_PERMISSION_REQUEST_CODE = 1
}
}
}
// [END maps_android_sample_my_location]
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -184,6 +187,7 @@ class PolygonDemoActivity :
}

}
// [END maps_android_sample_polygons]

/**
* Creates a List of LatLngs that form a rectangle with the given dimensions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]) {
Expand Down

0 comments on commit fa63927

Please sign in to comment.