Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ final class AnimatedCurrentLocationViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

// Register this sample with Google Maps for usage tracking
registerAttribution()

// Setup location services
guard CLLocationManager.locationServicesEnabled() else {
print("Please enable location services")
Expand All @@ -58,6 +61,13 @@ final class AnimatedCurrentLocationViewController: UIViewController {
locationManager.distanceFilter = 5.0
locationManager.startUpdatingLocation()
}

private func registerAttribution() {
// Use custom shorter ID due to long class name: AnimatedCurrentLocationViewController -> animatedlocation
let majorVersion = GMSServices.sdkVersion().components(separatedBy: ".").first ?? "10"
let attributionID = "gmp_git_iosmapssamples_v\(majorVersion)_animatedlocation"
GMSServices.addInternalUsageAttributionID(attributionID)
}
}

extension AnimatedCurrentLocationViewController: CLLocationManagerDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import UIKit

// Sample code for customizing the marker.
class AnimatedUIViewMarkerViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private lazy var mapView: GMSMapView = {
let camera = GMSCameraPosition(latitude: -33.8683, longitude: 151.2086, zoom: 5)
Expand Down Expand Up @@ -44,6 +46,9 @@ class AnimatedUIViewMarkerViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)

NotificationCenter.default.addObserver(
self, selector: #selector(applicationWillEnterForeground),
name: UIApplication.willEnterForegroundNotification, object: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import GoogleMaps
import UIKit

class CameraViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private let interval: TimeInterval = 1 / 30

Expand All @@ -32,6 +34,12 @@ class CameraViewController: UIViewController {

private var timer: Timer?

override func viewDidLoad() {
super.viewDidLoad()
// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)
}

override func loadView() {
// Opt the MapView into automatic dark mode switching.
mapView.overrideUserInterfaceStyle = .unspecified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import GoogleMaps
import UIKit

class CustomIndoorViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private lazy var mapView: GMSMapView = {
let camera = GMSCameraPosition(latitude: 37.78318, longitude: -122.403874, zoom: 18)
let options = GMSMapViewOptions()
Expand All @@ -29,6 +32,9 @@ class CustomIndoorViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)

view.backgroundColor = .gray

mapView.settings.myLocationButton = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import UIKit

// Sample code for customizing the marker.
class CustomMarkersViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private var markerCount = 0

private lazy var mapView: GMSMapView = {
Expand All @@ -26,6 +29,12 @@ class CustomMarkersViewController: UIViewController {
return GMSMapView(options: options)
}()

override func viewDidLoad() {
super.viewDidLoad()
// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)
}

override func loadView() {
// Opt the MapView into automatic dark mode switching.
mapView.overrideUserInterfaceStyle = .unspecified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ private class SliderControls {
}

class DataDrivenStylingBasicViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private lazy var config = [
FeatureLayerConfig(
Expand Down Expand Up @@ -165,6 +167,9 @@ class DataDrivenStylingBasicViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)

mainView = featureTypeSelectionLabel

segmentedControl.addTarget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import UIKit
private let mapIDWithMultipleLayers = ""

class DataDrivenStylingEventsViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()
private let sectionIdentifierForLayerToggles = "sectionIdentifierForLayerToggles"
private let cellIdentifier = "cellIdentifier"

Expand Down Expand Up @@ -83,6 +85,9 @@ class DataDrivenStylingEventsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)

if mapID.isEmpty {
promptForMapID(description: "with all data-driven styling layers enabled") {
self.mapID = $0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ class NotCapturingTouchesTableView: UITableView {
}

class DataDrivenStylingSearchViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private let cellIdentifier = "cellIdentifier"

fileprivate let urlSession = URLSession(
Expand Down Expand Up @@ -251,6 +254,9 @@ class DataDrivenStylingSearchViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)
if mapID.isEmpty {
promptForMapID(description: "with all data-driven styling layers enabled") {
self.mapID = $0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import GoogleMaps
import UIKit

class DoubleMapViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private lazy var sanFranciscoCamera = GMSCameraPosition(
latitude: 37.7847, longitude: -122.41, zoom: 5)
Expand Down Expand Up @@ -44,6 +46,9 @@ class DoubleMapViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)

mapView.delegate = self
mapView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(mapView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import GoogleMaps
import UIKit

class FitBoundsViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private let markerImageName = "glow-marker"

Expand Down Expand Up @@ -58,6 +60,9 @@ class FitBoundsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)

markers.forEach { marker in
marker.map = mapView
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ import GoogleMaps
import UIKit

class FixedPanoramaViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

override func viewDidLoad() {
super.viewDidLoad()
// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)
}

override func loadView() {
let panoramaView = GMSPanoramaView(frame: .zero)
panoramaView.moveNearCoordinate(.mountainSceneLocation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import GoogleMaps
import UIKit

class FrameRateViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private lazy var mapView: GMSMapView = {
let camera = GMSCameraPosition(latitude: -33.868, longitude: 151.2086, zoom: 6)
Expand Down Expand Up @@ -55,6 +57,12 @@ class FrameRateViewController: UIViewController {
])
}

override func viewDidLoad() {
super.viewDidLoad()
// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)
}

@objc func changeFrameRate() {
mapView.preferredFrameRate = nextFrameRate()
updateStatus()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import UIKit

// Sample code for GeoCoder service.
class GeocoderViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private lazy var mapView: GMSMapView = {
let camera = GMSCameraPosition(latitude: -33.868, longitude: 151.2086, zoom: 12)
Expand All @@ -34,6 +36,12 @@ class GeocoderViewController: UIViewController {
// Opt the MapView into automatic dark mode switching.
mapView.overrideUserInterfaceStyle = .unspecified
}

override func viewDidLoad() {
super.viewDidLoad()
// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)
}
}

extension GeocoderViewController: @MainActor GMSMapViewDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import GoogleMaps
import UIKit

class GestureControlViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private let holderHeight: CGFloat = 60
private let zoomLabelInset: CGFloat = 16

Expand All @@ -30,6 +33,9 @@ class GestureControlViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)

// Opt the MapView into automatic dark mode switching.
mapView.overrideUserInterfaceStyle = .unspecified

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ struct Coordinate: Decodable {
}

final class GradientPolylinesViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private lazy var mapView: GMSMapView = {
let camera = GMSCameraPosition(
Expand All @@ -53,6 +55,8 @@ final class GradientPolylinesViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)
addTrackToMap()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import GoogleMaps
import UIKit

final class GroundOverlayViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

override func loadView() {
let southWest = CLLocationCoordinate2D(latitude: 40.712216, longitude: -74.22655)
let northEast = CLLocationCoordinate2D(latitude: 40.773941, longitude: -74.12544)
Expand Down Expand Up @@ -43,6 +46,12 @@ final class GroundOverlayViewController: UIViewController {
groundOverlay.bounds = overlayBounds
groundOverlay.map = mapView
}

override func viewDidLoad() {
super.viewDidLoad()
// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)
}
}

extension GroundOverlayViewController: @MainActor GMSMapViewDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ struct Exhibit: Decodable {
}

class IndoorMuseumNavigationViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private lazy var mapView: GMSMapView = {
let camera = GMSCameraPosition(latitude: 38.8879, longitude: -77.0200, zoom: 17)
let options = GMSMapViewOptions()
Expand All @@ -60,6 +63,9 @@ class IndoorMuseumNavigationViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)

mapView.delegate = self
mapView.indoorDisplay.delegate = self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import GoogleMaps
import UIKit

class IndoorViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

let mapStyleOptions: [SampleMapStyle] = [.retro, .grayscale, .night, .normal]
private lazy var mapView: GMSMapView = {
Expand All @@ -34,6 +36,12 @@ class IndoorViewController: UIViewController {
view = mapView
}

override func viewDidLoad() {
super.viewDidLoad()
// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)
}

func alertAction(_ sampleMapStyle: SampleMapStyle) -> UIAlertAction {
return UIAlertAction(title: sampleMapStyle.description, style: .default) { [weak self] _ in
self?.mapView.mapStyle = sampleMapStyle.mapStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import GoogleMaps
import UIKit

class MapLayerViewController: UIViewController {
/// Manages Google Maps SDK usage attribution for this sample.
private let attributionManager: GoogleMapsAttributionManaging = GoogleMapsAttributionManager()

private let duration: TimeInterval = 2

private lazy var mapView: GMSMapView = {
Expand All @@ -37,6 +40,12 @@ class MapLayerViewController: UIViewController {
title: "Fly to My Location", style: .plain, target: self, action: #selector(tapMyLocation))
}

override func viewDidLoad() {
super.viewDidLoad()
// Register this sample with Google Maps for usage tracking
attributionManager.addAttribution(for: self)
}

@objc func tapMyLocation() {
guard let location = mapView.myLocation, CLLocationCoordinate2DIsValid(location.coordinate)
else {
Expand Down
Loading
Loading