Skip to content

Commit

Permalink
refactor: naming changes and general updates
Browse files Browse the repository at this point in the history
  • Loading branch information
waynewbishop committed Dec 9, 2024
1 parent 9e74292 commit 5a711de
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class MapExamplesViewModel: ObservableObject {
destination: AnyView(BasicMap())
),
MapExample(
title: "Map with Street Level",
title: "Map with custom camera",
description: "Map camera position set to street-level 3D perspective.",
destination: AnyView(MapWithStreetLevel())
destination: AnyView(MapWithCustomCamera())
),
MapExample(
title: "Map with marker",
Expand All @@ -38,19 +38,19 @@ class MapExamplesViewModel: ObservableObject {
destination: AnyView(MapWithMarkers())
),
MapExample(
title: "Map with Types",
title: "Map types",
description: "How to set the satellite, terrain, or hybrid map type property.",
destination: AnyView(MapWithTypes())
destination: AnyView(MapTypes())
),
MapExample(
title: "Map with Containers",
title: "Map with containers",
description: "Shows integration with SwiftUI layouts, allowing for standard modifiers like frame and padding.",
destination: AnyView(MapWithContainer())
),
MapExample(
title: "Map with Delegates",
title: "Handle map events",
description: "A GoogleMapView configured with handlers for map and marker tap events.",
destination: AnyView(MapWithDelegate())
destination: AnyView(HandleMapEvents())
)
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ struct GoogleMaps_SwiftUIApp: App {
/*
API Key Setup:
1. Create a .xcconfig file at the project root level
2. Add this line: API_KEY = your_api_key_here
2. Add this line: MAPS_API_KEY = your_api_key_here
3. Get an API key from: https://developers.google.com/maps/documentation/ios-sdk/get-api-key
4. Replace "your_api_key_here" with the API key obtained in step 3

Note: Never commit your actual API key to source control
*/

guard let infoDictionary: [String: Any] = Bundle.main.infoDictionary else {
fatalError("Info.plist not found")
}
guard let apiKey: String = infoDictionary["API_KEY"] as? String else {
fatalError("API_KEY not set in Info.plist")
guard let apiKey: String = infoDictionary["MAPS_API_KEY"] as? String else {
fatalError("MAPS_API_KEY not set in Info.plist")
}
let _ = GMSServices.provideAPIKey(apiKey)

Expand Down
4 changes: 2 additions & 2 deletions GoogleMaps-SwiftUI/GoogleMaps-SwiftUI/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>$(API_KEY)</string>
<key>MAPS_API_KEY</key>
<string>$(MAPS_API_KEY)</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import SwiftUI
import GoogleMaps

struct MapWithDelegate: View {
struct HandleMapEvents: View {

@State var response: String = ""

Expand Down
44 changes: 44 additions & 0 deletions GoogleMaps-SwiftUI/GoogleMaps-SwiftUI/Samples/MapTypes.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2024 Google LLC. All rights reserved.
//
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
// ANY KIND, either express or implied. See the License for the specific language governing
// permissions and limitations under the License.

import SwiftUI
import GoogleMaps

struct MapTypes: View {
// Initial options - set once at creation
private let mapOptions: GMSMapViewOptions = {
var options = GMSMapViewOptions()
options.camera = .camera(.googleplex)
return options
}()

@State private var mapType: GMSMapViewType = .terrain

var body: some View {
VStack {
GoogleMapView(options: mapOptions)
.mapType(mapType)
.ignoresSafeAreaExceptTop()

// Available map types:
// .normal - Standard road map with streets, political boundaries, and labels
// .satellite - Satellite imagery without street labels or overlays
// .terrain - Topographic data showing elevation, vegetation, and natural features
// .hybrid - Satellite imagery combined with road overlays and place labels
Button("Switch to Satellite") {
mapType = .satellite
}
.padding()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import SwiftUI
import GoogleMaps

struct MapWithStreetLevel: View {
struct MapWithCustomCamera: View {

private var mapOptions: GMSMapViewOptions = {
var options = GMSMapViewOptions()
Expand Down
40 changes: 0 additions & 40 deletions GoogleMaps-SwiftUI/GoogleMaps-SwiftUI/Samples/MapWithTypes.swift

This file was deleted.

0 comments on commit 5a711de

Please sign in to comment.