Resetting/Updating Markers in Google Maps ios (swift3)

I am building an ios application that uses a google map to display the location of the places return in the server. I manage to display the result in the initial load of the map, but when I want to search new plaaces and reload the markers in the map. Unfortunately the app was crashes.

Hope for your help.

Thank you.

Here is my code in the ViewController to initially display the markers:

func setUpMap() {

    let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 10.0)
    self.mapView.camera = camera
    let map_view = GMSMapView.map(withFrame: CGRect.zero, camera: camera)

    for data in arrData {

        let long = data["LONGITUDE"].string!
        let lat = data["LATITUDE"].string!

        if long != "" || lat != "" {

            let marker = GMSMarker()
            marker.position = CLLocationCoordinate2D(latitude: CLLocationDegrees(lat)!, longitude: CLLocationDegrees(long)!)
            marker.title = ""
            marker.snippet = "Hey, this is sample"
            marker.icon = UIImage(named: "locator")
            marker.map = self.mapView

            bounds = bounds.includingCoordinate(marker.position)

        }

    }

    // fit to bounds
    mapView.animate(with: GMSCameraUpdate.fit(bounds, withPadding: 50.0))

    self.mapView = map_view

}

Here is my code to reload/reset the markers in the map.

func reloadMarkers() {

    self.mapView.clear()

    let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 10.0)
    self.mapView.camera = camera
    let map_view = GMSMapView.map(withFrame: CGRect.zero, camera: camera)


    var _bounds = GMSCoordinateBounds()
    for data in arrData {

        let long = data["LONGITUDE"].string!
        let lat = data["LATITUDE"].string!

        if long != "" || lat != "" {

            let marker = GMSMarker()
            marker.position = CLLocationCoordinate2D(latitude: CLLocationDegrees(lat)!, longitude: CLLocationDegrees(long)!)
            marker.title = ""
            marker.snippet = "Hey, this is sample"
            marker.icon = UIImage(named: "locator")
            marker.map = self.mapView

            _bounds = _bounds.includingCoordinate(marker.position)

        }

    }

    // fit to bounds
    mapView.animate(with: GMSCameraUpdate.fit(bounds, withPadding: 50.0))

    self.mapView = map_view


}

Thanks for the help.
Cheers!

I found a solution, please see sample code below.

func reloadMarkers() {

    let camera = GMSCameraPosition.camera(withLatitude: 12.0377995, longitude: 122.6408281, zoom: 10.0)
    let map_view = GMSMapView.map(withFrame: self.brachMapView.bounds, camera: camera)
    map_view.camera = camera

    var bounds = GMSCoordinateBounds()

    for data in arrData {

        let long = data["LONGITUDE"].string!
        let lat = data["LATITUDE"].string!

        if long != "" || lat != "" {

            let marker = GMSMarker()
            marker.position = CLLocationCoordinate2D(latitude: CLLocationDegrees(lat)!, longitude: CLLocationDegrees(long)!)
            marker.title = ""
            marker.snippet = "Hey, this is sample"
            marker.icon = UIImage(named: "locator")
            marker.map = map_view

            bounds = bounds.includingCoordinate(marker.position)

        }

    }

    // fit to bounds
    map_view.animate(with: GMSCameraUpdate.fit(bounds, withPadding: 50.0))

    self.brachMapView.addSubview(map_view)
}

Thanks.

Cheers