Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong type description on the step 7 "Add markers to the map" on "Add a map to your iOS app with SwiftUI (Swift)" tutorial. #9

Open
Suprafen opened this issue Feb 1, 2023 · 0 comments

Comments

@Suprafen
Copy link

Suprafen commented Feb 1, 2023

Issue description

In the example bellow CitiesList described as a class in the message before code snippet. Which is not correct.

Notice that ContentView uses the markers property to render the list of cities by passing it to the CitiesList class.

struct CitiesList: View {

  @Binding var markers: [GMSMarker]

  var body: some View {
    GeometryReader { geometry in
      VStack(spacing: 0) {
        // ...
        // List of Cities
        List {
          ForEach(0..<self.markers.count) { id in
            let marker = self.markers[id]
            Button(action: {
              buttonAction(marker)
            }) {
              Text(marker.title ?? "")
            }
          }
        }.frame(maxWidth: .infinity)
      }
    }
  }
}

Suggested solutions

  1. Substitute the word class with struct as shown bellow:

Notice that ContentView uses the markers property to render the list of cities by passing it to the CitiesList struct.

  1. Or just leave it as suggested in this example:

Notice that ContentView uses the markers property to render the list of cities by passing it to the CitiesList.

Additional Info

The issue can be observed on the link https://developers.google.com/codelabs/maps-platform/maps-platform-ios-swiftui#6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant