@@ -72,7 +72,8 @@ class MapViewController: UIViewController {
7272 let cameraUpdate = GMSCameraUpdate . fit ( mapBounds)
7373 print ( cameraUpdate)
7474 mapView. moveCamera ( cameraUpdate)
75- locationManager. startUpdatingLocation ( )
75+ locationManager. startUpdatingLocation ( )
76+ makeGetRequest ( )
7677 }
7778 func scheduledTimerWithTimeInterval( ) {
7879 // Scheduling timer to Call the function "updateCounting" with the interval of 1 seconds
@@ -135,10 +136,9 @@ class MapViewController: UIViewController {
135136 let myCoords = ( locationManager. location? . coordinate) !
136137 let quickone = " ( " + myCoords. latitude. description
137138 let tempone = quickone
138- + " , " + myCoords. latitude . description
139+ + " , " + myCoords. longitude . description
139140 let sourcefinal = tempone + " ) "
140- print ( sourcefinal)
141- let parameters = [ " location " : " temp " , " radius " : " 5 " ] as Dictionary < String , String >
141+ let parameters = [ " location " : sourcefinal, " radius " : " 5 " ] as Dictionary < String , String >
142142
143143
144144 do {
@@ -149,28 +149,38 @@ class MapViewController: UIViewController {
149149 }
150150 print ( " EVEN GETTING HERE " )
151151 Alamofire . request ( request) . responseJSON { ( response) in
152- var temp = response. value!
153- print ( temp )
154- self . renderData ( responseData: response . description )
152+ let temp = response. value! as? [ Any ]
153+ print ( " SHE WORKING ME " )
154+ self . renderData ( responseData: temp! )
155155
156156 }
157157 }
158158
159- func renderData( responseData: String ) {
159+ func renderData( responseData: [ Any ] ) {
160160 // do some parsing to get the individual coordinates
161161 // assuming we create some list:
162162 // we're basically going to iterate through list and add them all to a path
163163 let path = GMSMutablePath ( )
164164 // latitude: 37.8716,longitude: -122.2727
165- let names = [ ( 37.9716 , - 122.2727 ) , ( 37.6716 , - 122.2727 ) , ( 37.7716 , - 122.2727 ) ]
166- for name in names {
167- path. add ( CLLocationCoordinate2D ( latitude: CLLocationDegrees ( name. 0 ) , longitude: CLLocationDegrees ( name. 1 ) ) )
165+ for name in responseData {
166+ let myCurrent = name as? Dictionary < String , Any >
167+ let start_location = myCurrent![ " startLocation " ] as? [ Double ]
168+ let end_location = myCurrent![ " endlocation " ] as? [ Double ]
169+ let contract_id = myCurrent![ " _id " ]
170+ let validity = myCurrent![ " valid " ]
171+ let price = myCurrent![ " price " ]
172+ let position = CLLocationCoordinate2D ( latitude: CLLocationDegrees ( start_location![ 0 ] ) , longitude: CLLocationDegrees ( start_location![ 1 ] ) )
173+ let marker = GMSMarker ( position: position)
174+ marker. title = " Random "
175+ marker. map = mapView
176+ path. add ( CLLocationCoordinate2D ( latitude: CLLocationDegrees ( start_location![ 0 ] ) , longitude: CLLocationDegrees ( start_location![ 1 ] ) ) )
168177 }
169178 if locationManager. location != nil {
170179 path. add ( ( locationManager. location? . coordinate) !)
171180 mapView? . isMyLocationEnabled = true
172181 }
173182 //Update your mapView with path
183+ print ( " HERE " )
174184 let mapBounds = GMSCoordinateBounds ( path: path)
175185 let cameraUpdate = GMSCameraUpdate . fit ( mapBounds)
176186 mapView. moveCamera ( cameraUpdate)
0 commit comments