This document serves as a comprehensive developer reference mapping high-level concepts directly to source code examples.
This section maps high-level concepts (groups) to specific demonstration files and lines, split by language.
Snippets demonstrating camera controls, zoom constraints, bounds, and animations.
Snippets demonstrating Google Cloud Console map customization capabilities loaded via Map ID.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Reusable Map Stylemaps_android_cloud_reusable_style |
What it does: Loads a reusable map style created in Google Cloud Console using a designated Map ID.\nHow to see the effect: The map view renders with custom color schemes and branding configured in Cloud Console. | CloudCustomizationSnippets.kt |
2. Style Roads and Polygonsmaps_android_cloud_style_roads |
What it does: Applies custom fill colors, stroke widths, and geometry styles to road networks and land polygons.\nHow to see the effect: Highways and arterial roads render using custom colors and geometry widths defined in Cloud Console. | CloudCustomizationSnippets.kt |
3. Feature Visibility Togglingmaps_android_cloud_feature_visibility |
What it does: Toggles the visibility of specific base map feature layers (such as transit lines or water bodies).\nHow to see the effect: Target base map feature elements appear hidden or visible according to cloud style configuration. | CloudCustomizationSnippets.kt |
4. Style Icons and Text Labelsmaps_android_cloud_style_labels |
What it does: Customizes typography, text label colors, and POI icon artwork across base map elements.\nHow to see the effect: Place names and POI icons display with customized colors and typography styling. | CloudCustomizationSnippets.kt |
5. Zoom-Level Stylingmaps_android_cloud_zoom_styling |
What it does: Configures scale-dependent visual styles that change dynamically across zoom levels.\nHow to see the effect: Zooming in or out dynamically shifts feature colors, label visibility, and geometry detail density. | CloudCustomizationSnippets.kt |
6. POI Density Filteringmaps_android_cloud_poi_density |
What it does: Adjusts point-of-interest display density rules configured in Google Cloud Console.\nHow to see the effect: The map displays a higher or lower concentration of commercial and tourist POI icons. | CloudCustomizationSnippets.kt |
7. Style Buildingsmaps_android_cloud_style_buildings |
What it does: Enables and styles 2D building footprints and 3D extruded building models.\nHow to see the effect: 3D architectural building shapes extrude visually from the map surface in dense urban areas. | CloudCustomizationSnippets.kt |
8. Style Landmarksmaps_android_cloud_style_landmarks |
What it does: Applies custom styling and highlight pin colors to major natural and urban landmarks.\nHow to see the effect: Famous landmarks (such as museums or monuments) display custom highlight pin icons. | CloudCustomizationSnippets.kt |
Snippets demonstrating custom Cloud geospatial dataset feature layers, attribute styling, and click events.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Dataset - Boulder Trailsmaps_android_dds_boulder_trails |
What it does: Fetches a Cloud OSMP Boulder Trails dataset layer and dynamically styles trail lines by difficulty or dog regulations.\nHow to see the effect: Trail lines render in green (Easy), blue (Moderate), or red (Difficult), with line thickness indicating dog restrictions. | DatasetLayerSnippets.kt |
2. Dataset - NYC Squirrelsmaps_android_dds_nyc_squirrels |
What it does: Imports a Cloud Central Park Squirrel Sightings dataset layer and styles point features by fur color.\nHow to see the effect: Point markers display across Central Park colored by squirrel fur color (black, cinnamon, gray). | DatasetLayerSnippets.kt |
3. Dataset - Kyoto Temples (Clickable)maps_android_dds_kyoto_temples |
What it does: Renders Cloud Kyoto temple boundary polygons and updates clicked polygon styling to highlight yellow.\nHow to see the effect: Temple grounds render in semi-transparent blue; tap any temple polygon to highlight it in yellow. | DatasetLayerSnippets.kt |
Snippets demonstrating administrative boundary feature layers, polygon styling, and click events.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Boundaries - Localities (Hana, HI)maps_android_dds_locality_boundary |
What it does: Fetches the LOCALITY FeatureLayer and styles Hana, HI (Place ID: ChIJ0zQtYiWsVHkRk8lRoB1RNPo) with a 50% opacity purple fill.\nHow to see the effect: Hana, Hawaii displays highlighted with a purple boundary polygon. | DataDrivenBoundarySnippets.kt |
2. Boundaries - Admin Area 1 (States)maps_android_dds_state_boundaries |
What it does: Fetches the ADMINISTRATIVE_AREA_LEVEL_1 FeatureLayer and styles state boundaries with unique colors derived from Place ID hashes.\nHow to see the effect: US state boundaries display with multi-colored semi-transparent polygon fills. | DataDrivenBoundarySnippets.kt |
3. Boundaries - Countries (Interactive)maps_android_dds_country_interactive |
What it does: Fetches the COUNTRY FeatureLayer and toggles country polygon fill colors between 10% black and 33% red on tap.\nHow to see the effect: Tap any country boundary to highlight its area in red; tap again to deselect. | DataDrivenBoundarySnippets.kt |
Snippets demonstrating clicks, camera events, POI clicks and indoor building levels.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. MapView Disable Click Eventmaps_android_events_disable_clicks_mapview |
What it does: Sets setClickable(false) on the underlying MapView container.\nHow to see the effect: Direct tap interaction on the map view is disabled. | EventsSnippets.kt |
2. Map Fragment Disable Click Eventmaps_android_events_disable_clicks_mapfragment |
What it does: Sets setClickable(false) on the SupportMapFragment root view container.\nHow to see the effect: Touch interactions on the map fragment view are ignored. | EventsSnippets.kt |
3. Active Indoor Building Levelmaps_android_events_active_level |
What it does: Queries map.getFocusedBuilding() to retrieve active indoor level indices.\nHow to see the effect: Active floor level information is extracted when viewing an indoor building plan. | EventsSnippets.kt |
4. POI Click Listenermaps_android_on_poi_click_demo |
What it does: Registers an OnPoiClickListener to capture tap events on Points of Interest.\nHow to see the effect: Tap any POI icon (such as a park or business); a Toast popup displays its name, Place ID, and location. | EventsSnippets.kt |
Snippets showing how to initialize, configure map options, types, and renderers.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Basic Map Activitymaps_android_mapsactivity |
What it does: Initializes an interactive map centered on Sydney, Australia and adds a title marker.\nHow to see the effect: The viewport opens directly on Sydney with a default red marker at LatLng(-34.0, 151.0). | MapInitSnippets.kt |
2. Map Fragment Transactionmaps_android_map_fragment |
What it does: Dynamically adds a SupportMapFragment into the Activity view hierarchy programmatically.\nHow to see the effect: A new map fragment view is instantiated and rendered into the container layout frame. | MapInitSnippets.kt |
3. Set Map Typemaps_android_map_type |
What it does: Sets the map type to Hybrid (satellite imagery overlaid with road and landmark labels).\nHow to see the effect: Map visual tiles switch from vector lines to satellite imagery with label overlays. | MapInitSnippets.kt |
4. Google Map Optionsmaps_android_google_map_options |
What it does: Configures initial map options programmatically (Satellite map type, disabled compass, tilt, and rotation gestures).\nHow to see the effect: The map opens in satellite view with rotation and tilt touch gestures disabled. | MapInitSnippets.kt |
5. Support Map Fragment Map IDmaps_android_support_map_fragment_map_id |
What it does: Configures a SupportMapFragment with a Cloud Map ID for cloud-based map styling.\nHow to see the effect: The map fragment binds to Google Cloud Console custom styling rules associated with the Map ID. | MapInitSnippets.kt |
6. MapView Map IDmaps_android_mapview_map_id |
What it does: Instantiates a programmatic MapView bound to a Cloud Map ID.\nHow to see the effect: The custom MapView renders with cloud styling and feature visibility configured in Cloud Console. | MapInitSnippets.kt |
7. Lite Mode Optionsmaps_android_lite_mode_options |
What it does: Enables Lite Mode on GoogleMapOptions to render a lightweight static map image.\nHow to see the effect: The map renders as a low-memory static image optimized for performance-constrained lists. | MapInitSnippets.kt |
8. Cloud-based Map Stylingmaps_android_cloud_based_map_styling |
What it does: Loads a MapFragment initialized with a Map ID stored in app resources.\nHow to see the effect: Custom styling, feature visibility, and color rules configured in Cloud Console are applied to the map. | MapInitSnippets.kt |
9. Renderer Opt-Inmaps_android_renderer_opt_in |
What it does: Requests the latest Maps SDK vector map renderer version via MapsInitializer.\nHow to see the effect: Inspect Android Logcat ('MapsDemo') to confirm whether Renderer.LATEST or Renderer.LEGACY is active. | MapInitSnippets.kt |
10. Set Map Color Schememaps_android_map_color_scheme |
What it does: Configures the map color scheme (Dark Mode / Light Mode / Follow System).\nHow to see the effect: Map visual colors shift to dark palette styling matching dark mode application preferences. | MapInitSnippets.kt |
11. Enable Traffic Layermaps_android_traffic_layer |
What it does: Enables the real-time traffic overlay layer on the map surface.\nHow to see the effect: Colored congestion lines (green/yellow/red) overlay major highways displaying live traffic conditions. | MapInitSnippets.kt |
Snippets demonstrating marker creation, styling, customization, and events.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Add a Markermaps_android_markers_add_a_marker |
What it does: Places a standard pin marker at LatLng(-33.852, 151.211) in Sydney, Australia.\nHow to see the effect: A red marker appears over Sydney; tap the pin to view its title callout. | MarkerSnippets.kt |
2. Draggable Markermaps_android_markers_draggable |
What it does: Creates a marker at Perth with draggability enabled (draggable = true).\nHow to see the effect: Long-press and drag the marker across the map surface to reposition it. | MarkerSnippets.kt |
3. Default Icon Markermaps_android_markers_default_icon |
What it does: Adds a standard Google Maps red pin marker at Melbourne.\nHow to see the effect: A standard red pin renders over central Melbourne. | MarkerSnippets.kt |
4. Custom Marker Colormaps_android_markers_custom_marker_color |
What it does: Sets a custom hue color (HUE_AZURE) on a marker pin.\nHow to see the effect: The marker renders with a cyan/azure colored pin instead of the default red hue. | MarkerSnippets.kt |
5. Marker Opacitymaps_android_markers_opacity |
What it does: Sets semi-transparency alpha (0.7f) on the marker pin.\nHow to see the effect: Map visual tiles beneath the marker show partially through the semi-transparent icon pin. | MarkerSnippets.kt |
6. Custom Marker Imagemaps_android_markers_image |
What it does: Replaces the default marker pin with a custom drawable image asset (arrow.png).\nHow to see the effect: An arrow icon graphic displays at Melbourne instead of a standard pin. | MarkerSnippets.kt |
7. Flat Markermaps_android_markers_flatten |
What it does: Aligns the marker flat against the map surface plane rather than billboarded toward camera.\nHow to see the effect: When you rotate or tilt the camera, the marker stays glued to the ground plane orientation. | MarkerSnippets.kt |
8. Rotate Markermaps_android_markers_rotate |
What it does: Applies a 90-degree rotation transform around the marker's center anchor point (0.5, 0.5).\nHow to see the effect: The marker icon appears rotated 90 degrees clockwise facing right. | MarkerSnippets.kt |
9. Marker Z-Indexmaps_android_markers_z_index |
What it does: Configures a high zIndex (1.0f) on a marker to force top stacking order precedence.\nHow to see the effect: The marker always renders on top of overlapping map polylines, shapes, or lower z-index pins. | MarkerSnippets.kt |
10. Marker Click Listener & Tagmaps_android_markers_tag_sample |
What it does: Associates click count state with markers using tag and listens for tap events.\nHow to see the effect: Tap any marker pin; a Toast message pops up displaying the updated click count. | MarkerSnippets.kt |
11. Add Info Windowmaps_android_info_windows_add |
What it does: Configures a marker with title details and population snippet text.\nHow to see the effect: Tap the marker to display an info callout window showing the title and population snippet. | MarkerSnippets.kt |
12. Show/Hide Info Windowmaps_android_info_windows_show_hide |
What it does: Programmatically calls showInfoWindow() and hideInfoWindow() on the marker instance.\nHow to see the effect: The info window popup programmatically displays and dismisses without user interaction. | MarkerSnippets.kt |
13. Info Window Click Listenermaps_android_info_windows_click_listener |
What it does: Listens for user touch click events inside the displayed info window callout.\nHow to see the effect: Open the marker info window and tap directly on the popup box to trigger a Toast notification. | MarkerSnippets.kt |
14. Marker Collision Behaviormaps_android_marker_collision |
What it does: Configures collision behavior on an AdvancedMarker (REQUIRED_AND_HIDES_OPTIONAL).\nHow to see the effect: Zoom or pan in dense marker clusters; optional overlapping markers hide to prevent clutter. | MarkerSnippets.kt |
Snippets demonstrating my location layer setup and button clicks.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Enable My Location Layermaps_android_my_location |
What it does: Enables the My Location blue dot layer and attaches click handlers for the location button and dot.\nHow to see the effect: A blue location dot renders at your device coordinates, and tapping the location button or blue dot triggers a Toast message. | MyLocationSnippets.kt |
Snippets demonstrating GroundOverlays and TileOverlays.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Ground Overlaysmaps_android_ground_overlays_add |
What it does: Binds an image bitmap (historical map graphic) to fixed geographic coordinates on the map surface.\nHow to see the effect: A historical 1922 map image overlays the ground in Newark, NJ. | OverlaySnippets.kt |
2. Ground Overlay Position Image Locationmaps_android_ground_overlays_position_image_location |
What it does: Configures ground overlay placement using anchor offset and center LatLng coordinates.\nHow to see the effect: The image aligns precisely relative to its anchor point and width/height dimensions. | OverlaySnippets.kt |
3. Ground Overlay Position Image Boundsmaps_android_ground_overlays_position_image_bounds |
What it does: Stretches and bounds a ground overlay image across a LatLngBounds rectangle.\nHow to see the effect: The image overlay scales to fit exactly within SW and NE geographic boundary corners. | OverlaySnippets.kt |
4. Tile Overlays Addmaps_android_tile_overlays_add |
What it does: Adds a custom TileOverlay layer backed by a custom web URL tile server (UrlTileProvider).\nHow to see the effect: Custom raster imagery tiles fetch and overlay the base map as you pan and zoom. | OverlaySnippets.kt |
5. Tile Overlays Transparencymaps_android_tile_overlays_transparency |
What it does: Configures and toggles semi-transparency (0.5f) on a custom tile overlay layer.\nHow to see the effect: Base map vector features show through the semi-transparent custom tile layer. | OverlaySnippets.kt |
Snippets demonstrating shapes, custom styled polylines, polygons, and circles.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Simple Polylinemaps_android_shapes_polylines_polylineoptions |
What it does: Creates a polyline path and connects sequential coordinates to form a rectangular boundary line.\nHow to see the effect: A solid stroke outline connects four geographic coordinates on the map. | ShapesSnippets.kt |
2. Simple Polygonmaps_android_shapes_polygons_polygonoptions |
What it does: Constructs a filled polygon covering a rectangular geographic region.\nHow to see the effect: A solid filled rectangular polygon shape overlays the map surface. | ShapesSnippets.kt |
3. Polygon Autocompletionmaps_android_shapes_polygons_autocompletion |
What it does: Demonstrates that open coordinate paths automatically join the last point back to origin.\nHow to see the effect: Unclosed polygon vertices automatically connect to form a closed, filled shape. | ShapesSnippets.kt |
4. Hollow Polygonmaps_android_shapes_polygons_hollow |
What it does: Adds interior coordinate hole paths (cutouts) inside an outer filled polygon boundary.\nHow to see the effect: A solid polygon displays with a transparent window cutout in its center. | ShapesSnippets.kt |
5. Circlemaps_android_shapes_circles_circleoptions |
What it does: Draws a circular shape specified by center coordinates and radius in meters.\nHow to see the effect: A circular overlay ring appears surrounding the center point with a 1,000 meter radius. | ShapesSnippets.kt |
6. Circle Click Eventmaps_android_shapes_circles_events |
What it does: Attaches a touch listener directly to a clickable circle shape overlay.\nHow to see the effect: Tap inside the circle shape; its border stroke color immediately flips. | ShapesSnippets.kt |
7. Custom Polyline Appearancemaps_android_shapes_custom_appearances |
What it does: Configures custom stroke patterns (dots and dashes), joint types, and custom cap icons.\nHow to see the effect: The polyline line renders with a dashed pattern and custom arrow icon end-cap. | ShapesSnippets.kt |
8. Associate Data Tagmaps_android_shapes_associate_data |
What it does: Attaches a custom metadata tag object ('A') to a clickable polyline.\nHow to see the effect: Click listeners can inspect the polyline's tag property for business logic routing. | ShapesSnippets.kt |
9. Multicolored Polyline Spansmaps_android_polyline_multicolored |
What it does: Applies multiple StyleSpan stroke colors to distinct segments along a single polyline.\nHow to see the effect: The polyline shifts colors from red to green across different segment lengths. | ShapesSnippets.kt |
10. Multicolored Gradient Polylinemaps_android_polyline_gradient |
What it does: Creates a smooth color gradient transition across a polyline segment using StrokeStyle.gradientBuilder.\nHow to see the effect: The polyline line smoothly blends from red to yellow along its continuous path. | ShapesSnippets.kt |
11. Stamped Texture Polylinemaps_android_polyline_stamped |
What it does: Stamps a repeating bitmap texture (walking dots) onto the polyline stroke using TextureStyle.\nHow to see the effect: A repeating sequence of walking dot icons renders along the polyline path. | ShapesSnippets.kt |
Snippets demonstrating Google Street View integration, camera movements, and panorama configuration.
| Feature & Region Tag | Description | Source |
|---|---|---|
| 1. Launch Street View Activity - |
What it does: Launches an Activity embedding a StreetViewPanoramaView initialized in San Francisco.\nHow to see the effect: A full-screen interactive 360-degree street view panorama opens. | StreetViewSnippets.kt:36 |
| 2. Set Panorama Location - |
What it does: Sets the panorama view geographic coordinates, search radius, and outdoor source filter.\nHow to see the effect: The Street View camera jumps directly to target coordinates. | StreetViewSnippets.kt:46 |
| 3. Zoom Panorama - |
What it does: Constructs a StreetViewPanoramaCamera configuration with an increased zoom level.\nHow to see the effect: The Street View perspective zooms closer into the street scene. | StreetViewSnippets.kt:59 |
| 4. Animate Camera - |
What it does: Configures camera bearing rotation (heading adjustment) for smooth panorama panning.\nHow to see the effect: The Street View panorama camera view rotates horizontally. | StreetViewSnippets.kt:75 |
Snippets demonstrating marker clustering, heatmaps, GeoJSON, KML, and Multilayer managers.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Marker Clustering Setupmaps_android_utils_clustering_cluster_manager |
What it does: Initializes a ClusterManager with 10 markers in close geographic proximity in London.\nHow to see the effect: Zooming out aggregates markers into numbered cluster circles; zooming in breaks them into pins. | UtilsSnippets.kt |
2. Disable Cluster Animationmaps_android_utils_clustering_animation_off |
What it does: Disables smooth position transition animations on ClusterManager.\nHow to see the effect: When zooming or panning, cluster pins immediately snap to position without smooth sliding. | UtilsSnippets.kt |
3. Add Clustering Info Window Itemmaps_android_utils_clustering_info_window |
What it does: Adds a single ClusterItem with a custom title and snippet to the ClusterManager.\nHow to see the effect: Tap the individual cluster item pin to view its custom title and snippet callout. | UtilsSnippets.kt |
3b. Clear Cluster Itemsmaps_android_utils_clustering_clear |
What it does: Clears all items and clusters from the ClusterManager.\nHow to see the effect: All cluster pin circles and individual cluster markers disappear from the map view. | UtilsSnippets.kt |
3c. Remove Single Cluster Itemmaps_android_utils_clustering_remove |
What it does: Removes a specified single item from the active ClusterManager collection.\nHow to see the effect: The target marker pin is removed and surrounding cluster count numbers decrement. | UtilsSnippets.kt |
3d. Cluster Listenersmaps_android_utils_clustering_listeners |
What it does: Registers click listeners for clusters, cluster items, and info window popups.\nHow to see the effect: Tapping a cluster circle or item displays a Toast notification with cluster details. | UtilsSnippets.kt |
4. GeoJSON Layer from JSONObjectmaps_android_util_geojson_add_jsonobject |
What it does: Constructs a GeoJsonLayer programmatically from an in-memory JSON object schema.\nHow to see the effect: Parsed GeoJSON points, lines, or polygons instantiate onto the map instance. | UtilsSnippets.kt |
5. Add GeoJSON Layer from Filemaps_android_util_geojson_add_file |
What it does: Imports and renders a GeoJSON dataset file from raw resources onto the map view.\nHow to see the effect: US geographic boundary lines and features render over the map in red vector lines. | UtilsSnippets.kt |
5b. Remove GeoJSON Layermaps_android_util_geojson_remove_layer |
What it does: Removes the imported GeoJSON layer from the active GoogleMap instance.\nHow to see the effect: All vector polylines and points associated with the GeoJSON dataset disappear. | UtilsSnippets.kt |
6. GeoJSON Features and Stylingmaps_android_util_geojson_point_feature |
What it does: Programmatically iterates, styles, and adds custom point and linestring GeoJsonFeatures.\nHow to see the effect: Draggable markers and styled lines render according to default GeoJson feature styles. | UtilsSnippets.kt |
7. KML Layer from File Resourcemaps_android_utils_kml_add_file |
What it does: Imports KML 3D building polygons from raw resource files and renders them over Mountain View.\nHow to see the effect: KML campus polygon outlines and placemarks render over the Google Campus. | UtilsSnippets.kt |
7b. Remove KML Layermaps_android_utils_kml_remove_layer |
What it does: Removes the imported KML layer from the active GoogleMap instance.\nHow to see the effect: All vector polylines, polygons, and placemarks associated with the KML dataset disappear. | UtilsSnippets.kt |
8. KML Layer from Input Streammaps_android_utils_kml_add_input_stream |
What it does: Parses a KML dataset stream, iterates nested placemark containers, and binds click listeners.\nHow to see the effect: Tap any KML feature line or placemark to trigger a log and view container hierarchy. | UtilsSnippets.kt |
9. Simple Heatmapmaps_android_utils_heatmap_simple |
What it does: Generates a HeatmapTileProvider visualization from police station coordinate data.\nHow to see the effect: A red/yellow density heatmap overlay displays over Melbourne showing location concentrations. | UtilsSnippets.kt |
10. Add Custom Heatmapmaps_android_utils_heatmap_customize |
What it does: Configures a custom color gradient (green to red), 0.7 opacity, and weighted data points.\nHow to see the effect: A custom green/red gradient heatmap overlay renders with custom transparency over the map. | UtilsSnippets.kt |
10b. Remove Custom Heatmapmaps_android_utils_heatmap_remove |
What it does: Removes the custom heatmap TileOverlay from the active GoogleMap instance.\nHow to see the effect: The heatmap color density overlay disappears completely from the viewport. | UtilsSnippets.kt |
11. Multilayer Collections Initmaps_android_utils_multilayer_init |
What it does: Demonstrates sharing MarkerManager, PolylineManager, and PolygonManager across GeoJSON, KML, and ClusterManager.\nHow to see the effect: Unclustered markers, GeoJSON features, and KML layers co-exist without event or rendering conflict. | UtilsSnippets.kt |
Snippets demonstrating camera controls, zoom constraints, bounds, and animations.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Zoom Level Constraintsmaps_android_camera_and_view_zoom_level |
What it does: Sets a minimum zoom level of 6.0 and maximum zoom level of 14.0 on the camera.\nHow to see the effect: Pinch to zoom in or out; zooming stops when reaching minimum zoom (level 6) or maximum zoom (level 14). | CameraControlSnippets.java |
2. Fit Camera To Bounds (Australia)maps_android_camera_and_view_setting_boundaries |
What it does: Moves the camera once to fit the entire geographic bounding box of Australia within the visible viewport.\nHow to see the effect: The map immediately shifts to frame all of Australia. (Does not restrict subsequent user panning.) | CameraControlSnippets.java |
3. Centering Map Within An Areamaps_android_camera_and_view_centering_within_area |
What it does: Centers the camera at the geographic midpoint of Australia at zoom level 10.\nHow to see the effect: The camera jumps directly to the center of Australia at a fixed zoom scale. | CameraControlSnippets.java |
4. Panning Restrictionsmaps_android_camera_and_view_panning_restrictions |
What it does: Constrains the camera target to the geographic bounding box of Adelaide.\nHow to see the effect: Drag or pan the map; scrolling stops when the camera center reaches the boundary of Adelaide. | CameraControlSnippets.java |
5. Common Map Movementsmaps_android_camera_and_view_common_map_movements |
What it does: Demonstrates instant camera placement, animated zoom transitions, and 3D orientation (bearing & tilt).\nHow to see the effect: Watch the map smoothly animate from Sydney to Mountain View with orientation and tilt changes. | CameraControlSnippets.java |
Snippets demonstrating Google Cloud Console map customization capabilities loaded via Map ID.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Reusable Map Stylemaps_android_cloud_reusable_style |
What it does: Loads a reusable map style created in Google Cloud Console using a designated Map ID.\nHow to see the effect: The map view renders with custom color schemes and branding configured in Cloud Console. | CloudCustomizationSnippets.java |
2. Style Roads and Polygonsmaps_android_cloud_style_roads |
What it does: Applies custom fill colors, stroke widths, and geometry styles to road networks and land polygons.\nHow to see the effect: Highways and arterial roads render using custom colors and geometry widths defined in Cloud Console. | CloudCustomizationSnippets.java |
3. Feature Visibility Togglingmaps_android_cloud_feature_visibility |
What it does: Toggles the visibility of specific base map feature layers (such as transit lines or water bodies).\nHow to see the effect: Target base map feature elements appear hidden or visible according to cloud style configuration. | CloudCustomizationSnippets.java |
4. Style Icons and Text Labelsmaps_android_cloud_style_labels |
What it does: Customizes typography, text label colors, and POI icon artwork across base map elements.\nHow to see the effect: Place names and POI icons display with customized colors and typography styling. | CloudCustomizationSnippets.java |
5. Zoom-Level Stylingmaps_android_cloud_zoom_styling |
What it does: Configures scale-dependent visual styles that change dynamically across zoom levels.\nHow to see the effect: Zooming in or out dynamically shifts feature colors, label visibility, and geometry detail density. | CloudCustomizationSnippets.java |
6. POI Density Filteringmaps_android_cloud_poi_density |
What it does: Adjusts point-of-interest display density rules configured in Google Cloud Console.\nHow to see the effect: The map displays a higher or lower concentration of commercial and tourist POI icons. | CloudCustomizationSnippets.java |
7. Style Buildingsmaps_android_cloud_style_buildings |
What it does: Enables and styles 2D building footprints and 3D extruded building models.\nHow to see the effect: 3D architectural building shapes extrude visually from the map surface in dense urban areas. | CloudCustomizationSnippets.java |
8. Style Landmarksmaps_android_cloud_style_landmarks |
What it does: Applies custom styling and highlight pin colors to major natural and urban landmarks.\nHow to see the effect: Famous landmarks (such as museums or monuments) display custom highlight pin icons. | CloudCustomizationSnippets.java |
Snippets demonstrating custom Cloud geospatial dataset feature layers, attribute styling, and click events.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Dataset - Boulder Trailsmaps_android_dds_boulder_trails |
What it does: Fetches a Cloud OSMP Boulder Trails dataset layer and dynamically styles trail lines by difficulty or dog regulations.\nHow to see the effect: Trail lines render in green (Easy), blue (Moderate), or red (Difficult), with line thickness indicating dog restrictions. | DatasetLayerSnippets.java |
2. Dataset - NYC Squirrelsmaps_android_dds_nyc_squirrels |
What it does: Imports a Cloud Central Park Squirrel Sightings dataset layer and styles point features by fur color.\nHow to see the effect: Point markers display across Central Park colored by squirrel fur color (black, cinnamon, gray). | DatasetLayerSnippets.java |
3. Dataset - Kyoto Temples (Clickable)maps_android_dds_kyoto_temples |
What it does: Renders Cloud Kyoto temple boundary polygons and updates clicked polygon styling to highlight yellow.\nHow to see the effect: Temple grounds render in semi-transparent blue; tap any temple polygon to highlight it in yellow. | DatasetLayerSnippets.java |
Snippets demonstrating administrative boundary feature layers, polygon styling, and click events.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Boundaries - Localities (Hana, HI)maps_android_dds_locality_boundary |
What it does: Fetches the LOCALITY FeatureLayer and styles Hana, HI (Place ID: ChIJ0zQtYiWsVHkRk8lRoB1RNPo) with a 50% opacity purple fill.\nHow to see the effect: Hana, Hawaii displays highlighted with a purple boundary polygon. | DataDrivenBoundarySnippets.java |
2. Boundaries - Admin Area 1 (States)maps_android_dds_state_boundaries |
What it does: Fetches the ADMINISTRATIVE_AREA_LEVEL_1 FeatureLayer and styles state boundaries with unique colors derived from Place ID hashes.\nHow to see the effect: US state boundaries display with multi-colored semi-transparent polygon fills. | DataDrivenBoundarySnippets.java |
3. Boundaries - Countries (Interactive)maps_android_dds_country_interactive |
What it does: Fetches the COUNTRY FeatureLayer and toggles country polygon fill colors between 10% black and 33% red on tap.\nHow to see the effect: Tap any country boundary to highlight its area in red; tap again to deselect. | DataDrivenBoundarySnippets.java |
Snippets demonstrating clicks, camera events, POI clicks and indoor building levels.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. MapView Disable Click Eventmaps_android_events_disable_clicks_mapview |
What it does: Sets setClickable(false) on the underlying MapView container.\nHow to see the effect: Direct tap interaction on the map view is disabled. | EventsSnippets.java |
2. Map Fragment Disable Click Eventmaps_android_events_disable_clicks_mapfragment |
What it does: Sets setClickable(false) on the SupportMapFragment root view container.\nHow to see the effect: Touch interactions on the map fragment view are ignored. | EventsSnippets.java |
3. Active Indoor Building Levelmaps_android_events_active_level |
What it does: Queries map.getFocusedBuilding() to retrieve active indoor level indices.\nHow to see the effect: Active floor level information is extracted when viewing an indoor building plan. | EventsSnippets.java |
4. POI Click Listenermaps_android_on_poi_click_demo |
What it does: Registers an OnPoiClickListener to capture tap events on Points of Interest.\nHow to see the effect: Tap any POI icon (such as a park or business); a Toast popup displays its name, Place ID, and location. | EventsSnippets.java |
Snippets showing how to initialize, configure map options, types, and renderers.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Basic Map Activitymaps_android_mapsactivity |
What it does: Initializes an interactive map centered on Sydney, Australia and adds a title marker.\nHow to see the effect: The viewport opens directly on Sydney with a default red marker at LatLng(-34.0, 151.0). | MapInitSnippets.java |
2. Map Fragment Transactionmaps_android_map_fragment |
What it does: Dynamically adds a SupportMapFragment into the Activity view hierarchy programmatically.\nHow to see the effect: A new map fragment view is instantiated and rendered into the container layout frame. | MapInitSnippets.java |
3. Set Map Typemaps_android_map_type |
What it does: Sets the map type to Hybrid (satellite imagery overlaid with road and landmark labels).\nHow to see the effect: Map visual tiles switch from vector lines to satellite imagery with label overlays. | MapInitSnippets.java |
4. Google Map Optionsmaps_android_google_map_options |
What it does: Configures initial map options programmatically (Satellite map type, disabled compass, tilt, and rotation gestures).\nHow to see the effect: The map opens in satellite view with rotation and tilt touch gestures disabled. | MapInitSnippets.java |
5. Support Map Fragment Map IDmaps_android_support_map_fragment_map_id |
What it does: Configures a SupportMapFragment with a Cloud Map ID for cloud-based map styling.\nHow to see the effect: The map fragment binds to Google Cloud Console custom styling rules associated with the Map ID. | MapInitSnippets.java |
6. MapView Map IDmaps_android_mapview_map_id |
What it does: Instantiates a programmatic MapView bound to a Cloud Map ID.\nHow to see the effect: The custom MapView renders with cloud styling and feature visibility configured in Cloud Console. | MapInitSnippets.java |
7. Lite Mode Optionsmaps_android_lite_mode_options |
What it does: Enables Lite Mode on GoogleMapOptions to render a lightweight static map image.\nHow to see the effect: The map renders as a low-memory static image optimized for performance-constrained lists. | MapInitSnippets.java |
8. Cloud-based Map Stylingmaps_android_cloud_based_map_styling |
What it does: Loads a MapFragment initialized with a Map ID stored in app resources.\nHow to see the effect: Custom styling, feature visibility, and color rules configured in Cloud Console are applied to the map. | MapInitSnippets.java |
9. Renderer Opt-Inmaps_android_renderer_opt_in |
What it does: Requests the latest Maps SDK vector map renderer version via MapsInitializer.\nHow to see the effect: Inspect Android Logcat ('MapsDemo') to confirm whether Renderer.LATEST or Renderer.LEGACY is active. | MapInitSnippets.java |
10. Set Map Color Schememaps_android_map_color_scheme |
What it does: Configures the map color scheme (Dark Mode / Light Mode / Follow System).\nHow to see the effect: Map visual colors shift to dark palette styling matching dark mode application preferences. | MapInitSnippets.java |
11. Enable Traffic Layermaps_android_traffic_layer |
What it does: Enables the real-time traffic overlay layer on the map surface.\nHow to see the effect: Colored congestion lines (green/yellow/red) overlay major highways displaying live traffic conditions. | MapInitSnippets.java |
Snippets demonstrating marker creation, styling, customization, and events.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Add a Markermaps_android_markers_add_a_marker |
What it does: Places a standard pin marker at LatLng(-33.852, 151.211) in Sydney, Australia.\nHow to see the effect: A red marker appears over Sydney; tap the pin to view its title callout. | MarkerSnippets.java |
2. Draggable Markermaps_android_markers_draggable |
What it does: Creates a marker at Perth with draggability enabled (draggable = true).\nHow to see the effect: Long-press and drag the marker across the map surface to reposition it. | MarkerSnippets.java |
3. Default Icon Markermaps_android_markers_default_icon |
What it does: Adds a standard Google Maps red pin marker at Melbourne.\nHow to see the effect: A standard red pin renders over central Melbourne. | MarkerSnippets.java |
4. Custom Marker Colormaps_android_markers_custom_marker_color |
What it does: Sets a custom hue color (HUE_AZURE) on a marker pin.\nHow to see the effect: The marker renders with a cyan/azure colored pin instead of the default red hue. | MarkerSnippets.java |
5. Marker Opacitymaps_android_markers_opacity |
What it does: Sets semi-transparency alpha (0.7f) on the marker pin.\nHow to see the effect: Map visual tiles beneath the marker show partially through the semi-transparent icon pin. | MarkerSnippets.java |
6. Custom Marker Imagemaps_android_markers_image |
What it does: Replaces the default marker pin with a custom drawable image asset (arrow.png).\nHow to see the effect: An arrow icon graphic displays at Melbourne instead of a standard pin. | MarkerSnippets.java |
7. Flat Markermaps_android_markers_flatten |
What it does: Aligns the marker flat against the map surface plane rather than billboarded toward camera.\nHow to see the effect: When you rotate or tilt the camera, the marker stays glued to the ground plane orientation. | MarkerSnippets.java |
8. Rotate Markermaps_android_markers_rotate |
What it does: Applies a 90-degree rotation transform around the marker's center anchor point (0.5, 0.5).\nHow to see the effect: The marker icon appears rotated 90 degrees clockwise facing right. | MarkerSnippets.java |
9. Marker Z-Indexmaps_android_markers_z_index |
What it does: Configures a high zIndex (1.0f) on a marker to force top stacking order precedence.\nHow to see the effect: The marker always renders on top of overlapping map polylines, shapes, or lower z-index pins. | MarkerSnippets.java |
10. Marker Click Listener & Tagmaps_android_markers_tag_sample |
What it does: Associates click count state with markers using tag and listens for tap events.\nHow to see the effect: Tap any marker pin; a Toast message pops up displaying the updated click count. | MarkerSnippets.java |
11. Add Info Windowmaps_android_info_windows_add |
What it does: Configures a marker with title details and population snippet text.\nHow to see the effect: Tap the marker to display an info callout window showing the title and population snippet. | MarkerSnippets.java |
12. Show/Hide Info Windowmaps_android_info_windows_show_hide |
What it does: Programmatically calls showInfoWindow() and hideInfoWindow() on the marker instance.\nHow to see the effect: The info window popup programmatically displays and dismisses without user interaction. | MarkerSnippets.java |
13. Info Window Click Listenermaps_android_info_windows_click_listener |
What it does: Listens for user touch click events inside the displayed info window callout.\nHow to see the effect: Open the marker info window and tap directly on the popup box to trigger a Toast notification. | MarkerSnippets.java |
14. Marker Collision Behaviormaps_android_marker_collision |
What it does: Configures collision behavior on an AdvancedMarker (REQUIRED_AND_HIDES_OPTIONAL).\nHow to see the effect: Zoom or pan in dense marker clusters; optional overlapping markers hide to prevent clutter. | MarkerSnippets.java |
Snippets demonstrating my location layer setup and button clicks.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Enable My Location Layermaps_android_my_location |
What it does: Enables the My Location blue dot layer and attaches click handlers for the location button and dot.\nHow to see the effect: A blue location dot renders at your device coordinates, and tapping the location button or blue dot triggers a Toast message. | MyLocationSnippets.java |
Snippets demonstrating GroundOverlays and TileOverlays.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Ground Overlaysmaps_android_ground_overlays_add |
What it does: Binds an image bitmap (historical map graphic) to fixed geographic coordinates on the map surface.\nHow to see the effect: A historical 1922 map image overlays the ground in Newark, NJ. | OverlaySnippets.java |
2. Ground Overlay Position Image Locationmaps_android_ground_overlays_position_image_location |
What it does: Configures ground overlay placement using anchor offset and center LatLng coordinates.\nHow to see the effect: The image aligns precisely relative to its anchor point and width/height dimensions. | OverlaySnippets.java |
3. Ground Overlay Position Image Boundsmaps_android_ground_overlays_position_image_bounds |
What it does: Stretches and bounds a ground overlay image across a LatLngBounds rectangle.\nHow to see the effect: The image overlay scales to fit exactly within SW and NE geographic boundary corners. | OverlaySnippets.java |
4. Tile Overlays Addmaps_android_tile_overlays_add |
What it does: Adds a custom TileOverlay layer backed by a custom web URL tile server (UrlTileProvider).\nHow to see the effect: Custom raster imagery tiles fetch and overlay the base map as you pan and zoom. | OverlaySnippets.java |
5. Tile Overlays Transparencymaps_android_tile_overlays_transparency |
What it does: Configures and toggles semi-transparency (0.5f) on a custom tile overlay layer.\nHow to see the effect: Base map vector features show through the semi-transparent custom tile layer. | OverlaySnippets.java |
Snippets demonstrating shapes, custom styled polylines, polygons, and circles.
| Feature & Region Tag | Description | Source |
|---|---|---|
1. Simple Polylinemaps_android_shapes_polylines_polylineoptions |
What it does: Creates a polyline path and connects sequential coordinates to form a rectangular boundary line.\nHow to see the effect: A solid stroke outline connects four geographic coordinates on the map. | ShapesSnippets.java |
2. Simple Polygonmaps_android_shapes_polygons_polygonoptions |
What it does: Constructs a filled polygon covering a rectangular geographic region.\nHow to see the effect: A solid filled rectangular polygon shape overlays the map surface. | ShapesSnippets.java |
3. Polygon Autocompletionmaps_android_shapes_polygons_autocompletion |
What it does: Demonstrates that open coordinate paths automatically join the last point back to origin.\nHow to see the effect: Unclosed polygon vertices automatically connect to form a closed, filled shape. | ShapesSnippets.java |
4. Hollow Polygonmaps_android_shapes_polygons_hollow |
What it does: Adds interior coordinate hole paths (cutouts) inside an outer filled polygon boundary.\nHow to see the effect: A solid polygon displays with a transparent window cutout in its center. | ShapesSnippets.java |
5. Circlemaps_android_shapes_circles_circleoptions |
What it does: Draws a circular shape specified by center coordinates and radius in meters.\nHow to see the effect: A circular overlay ring appears surrounding the center point with a 1,000 meter radius. | ShapesSnippets.java |
6. Circle Click Eventmaps_android_shapes_circles_events |
What it does: Attaches a touch listener directly to a clickable circle shape overlay.\nHow to see the effect: Tap inside the circle shape; its border stroke color immediately flips. | ShapesSnippets.java |
7. Custom Polyline Appearancemaps_android_shapes_custom_appearances |
What it does: Configures custom stroke patterns (dots and dashes), joint types, and custom cap icons.\nHow to see the effect: The polyline line renders with a dashed pattern and custom arrow icon end-cap. | ShapesSnippets.java |
8. Associate Data Tagmaps_android_shapes_associate_data |
What it does: Attaches a custom metadata tag object ('A') to a clickable polyline.\nHow to see the effect: Click listeners can inspect the polyline's tag property for business logic routing. | ShapesSnippets.java |
9. Multicolored Polyline Spansmaps_android_polyline_multicolored |
What it does: Applies multiple StyleSpan stroke colors to distinct segments along a single polyline.\nHow to see the effect: The polyline shifts colors from red to green across different segment lengths. | ShapesSnippets.java |
10. Multicolored Gradient Polylinemaps_android_polyline_gradient |
What it does: Creates a smooth color gradient transition across a polyline segment using StrokeStyle.gradientBuilder.\nHow to see the effect: The polyline line smoothly blends from red to yellow along its continuous path. | ShapesSnippets.java |
11. Stamped Texture Polylinemaps_android_polyline_stamped |
What it does: Stamps a repeating bitmap texture (walking dots) onto the polyline stroke using TextureStyle.\nHow to see the effect: A repeating sequence of walking dot icons renders along the polyline path. | ShapesSnippets.java |
Snippets demonstrating Google Street View integration, camera movements, and panorama configuration.
| Feature & Region Tag | Description | Source |
|---|---|---|
| 1. Launch Street View Activity - |
What it does: Launches an Activity embedding a StreetViewPanoramaView initialized in San Francisco.\nHow to see the effect: A full-screen interactive 360-degree street view panorama opens. | StreetViewSnippets.java:42 |
| 2. Set Panorama Location - |
What it does: Sets the panorama view geographic coordinates, search radius, and outdoor source filter.\nHow to see the effect: The Street View camera jumps directly to target coordinates. | StreetViewSnippets.java:51 |
| 3. Zoom Panorama - |
What it does: Constructs a StreetViewPanoramaCamera configuration with an increased zoom level.\nHow to see the effect: The Street View perspective zooms closer into the street scene. | StreetViewSnippets.java:62 |
| 4. Animate Camera - |
What it does: Configures camera bearing rotation (heading adjustment) for smooth panorama panning.\nHow to see the effect: The Street View panorama camera view rotates horizontally. | StreetViewSnippets.java:75 |
Snippets demonstrating marker clustering, heatmaps, GeoJSON, KML, and Multilayer managers.
