# Map Annotation not showing proper location when using variables

**URL:** <https://forums.swift.org/t/map-annotation-not-showing-proper-location-when-using-variables/59532>\
**Category:** Using Swift\
**Tags:** swiftui, firebase\
**Created:** [August 9, 2022, 2:02am UTC](https://forums.swift.org/t/map-annotation-not-showing-proper-location-when-using-variables/59532 "2022-08-09T02:02:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anish091234](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/anish091234/32/24713_2.png) [@Anish091234](https://forums.swift.org/u/Anish091234)\
**Post date:** [August 9, 2022, 2:02am UTC](https://forums.swift.org/t/map-annotation-not-showing-proper-location-when-using-variables/59532/1 "2022-08-09T02:02:13Z")

</div>

I have several users locations stored inside of my Firestore database, and called them all to a variable, and then I mapped both of them into a map annotation called `Marker(coordinate: CLLocationCoordinate2D(latitude: realLat, longitude: realLong))`. When I call the map:

Variables (called before the view): `@State var realLong = 0.00` and `@State var realLat = 0.00`

The `$viewmodel.region` can be anything, I've just set it to a location button.

The Map:

```swift
Map(coordinateRegion: $viewModel.region, showsUserLocation: true, annotationItems: markers) { markers in
    MapAnnotation(coordinate: markers.coordinate) {
        Circle()
    }
}

```

Firebase Function Code:

```swift
func downloadMapData() { 
        let db = Firestore.firestore()
        db.collection("annotations").addSnapshotListener {(snap, 
    err) in
            if err != nil{
                print("\(String(describing: err))")
                return
            }
            for i in snap!.documentChanges {
                _ = i.document.documentID
                if let latCoordinate = i.document.get("lat") as? 
   Double {
                    DispatchQueue.main.async {
                        realLat = latCoordinate
                        print("realLat: \(realLat)")
                    }
                }
            }
            for i in snap!.documentChanges {
                _ = i.document.documentID
                if let longCoordinate = i.document.get("long") as? 
    Double {
                    DispatchQueue.main.async {
                        realLong = longCoordinate
                        print("realLong: \(realLong)")
                    }
                }
            }
            
        }
    }

```

It shows up nowhere near the real place. I think that the coordinates might be smushed together.

Inside of the console I get this:

```swift
realLat: 37.3348892
realLat: 69.69
realLong: -122.0088363
realLong: 42.32

```

It look that if there might be 2 instances of the variables???

Is there any way I could make separate annotations for each off the users inside of my database, with each user getting their own map annotation? Thanks in advance!
