mirror of
https://github.com/googlemaps/android-samples.git
synced 2025-12-08 18:02:20 +00:00
chore: Add snippets for MapID. (#769)
Change-Id: I434662a7d99ae3b333a8e53c97813f6eafed7d68
This commit is contained in:
parent
6857d37ff8
commit
8549ee6253
25
snippets/app/src/gms/java/com/google/maps/example/MapId.java
Normal file
25
snippets/app/src/gms/java/com/google/maps/example/MapId.java
Normal file
@ -0,0 +1,25 @@
|
||||
package com.google.maps.example;
|
||||
|
||||
import android.content.Context;
|
||||
import com.google.android.gms.maps.GoogleMapOptions;
|
||||
import com.google.android.gms.maps.MapView;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
|
||||
class MapId {
|
||||
|
||||
private void fragment() {
|
||||
// [START maps_android_support_map_fragment_map_id]
|
||||
GoogleMapOptions options = new GoogleMapOptions()
|
||||
.mapId("YOUR_MAP_ID");
|
||||
SupportMapFragment mapFragment = SupportMapFragment.newInstance(options);
|
||||
// [END maps_android_support_map_fragment_map_id]
|
||||
}
|
||||
|
||||
private void mapView(Context context) {
|
||||
// [START maps_android_mapview_map_id]
|
||||
GoogleMapOptions options = new GoogleMapOptions()
|
||||
.mapId("YOUR_MAP_ID");
|
||||
MapView mapView = new MapView(context, options);
|
||||
// [END maps_android_mapview_map_id]
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.google.maps.example.kotlin
|
||||
|
||||
import android.content.Context
|
||||
import com.google.android.gms.maps.GoogleMapOptions
|
||||
import com.google.android.gms.maps.MapView
|
||||
import com.google.android.gms.maps.SupportMapFragment
|
||||
|
||||
internal class MapId {
|
||||
private fun fragment() {
|
||||
// [START maps_android_support_map_fragment_map_id]
|
||||
val options = GoogleMapOptions()
|
||||
.mapId("YOUR_MAP_ID")
|
||||
val mapFragment = SupportMapFragment.newInstance(options)
|
||||
// [END maps_android_support_map_fragment_map_id]
|
||||
}
|
||||
|
||||
private fun mapView(context: Context) {
|
||||
// [START maps_android_mapview_map_id]
|
||||
val options = GoogleMapOptions()
|
||||
.mapId("YOUR_MAP_ID")
|
||||
val mapView = MapView(context, options)
|
||||
// [END maps_android_mapview_map_id]
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user