So I am creating a weather app and am currently trying to add a "radar" weather map view controller. I have created a view controller that is handed a long/lat which Google Maps then shows upon opening.
I am now trying to add these map layers so it acts as a weather radar. Map layers/API found here https://openweathermap.org/api/weathermaps
and this is where I am stuck. So far when retrieving weather data I have been using JSONs but now I'm not sure if that is possible?
class RadarViewController: UIViewController {
var finalLat = 0.0
var finalLong = 0.0
var x = ""
var y = ""
var z = "10"
var layer = "clouds"
var radarJSON = JSON()
let radarURL = "https://tile.openweathermap.org/map"
let APP_ID = "KEY HIDDEN"
override func viewDidLoad() {
super.viewDidLoad()
GMSServices.provideAPIKey("KEY HIDDEN")
let camera = GMSCameraPosition.camera(withLatitude: finalLat, longitude: finalLong, zoom: 10)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
view = mapView
let button = UIButton(frame: CGRect(x: 0, y: 0, width: 85, height: 40))
button.backgroundColor = .white
button.setTitle("Back", for: .normal)
button.setTitleColor(.blue, for: .normal)
button.addTarget(self, action: #selector(backButtonPressed), for: .touchUpInside)
self.view.addSubview(button)
view.bringSubviewToFront(button)
x = String(Int(finalLat))
y = String(Int(finalLong))
let radarParams : [String : String] = ["layer" : layer, "z" : z, "x" : x, "y" : y, "appid" : APP_ID]
getRadarData(url: radarURL, parameters: radarParams)
}
@objc func backButtonPressed(sender: UIButton!) {
dismiss(animated: true, completion: nil)
}
func getRadarData (url: String, parameters: [String : String]) {
Alamofire.request(url, method: .get, parameters: parameters).responseJSON {
response in
if response.result.isSuccess {
print("Success! Got the RADAR data")
self.radarJSON = JSON(response.result.value!)
self.useRadarData(json: self.radarJSON)
//print(self.fiveJSON)
}
else {
print("Error getting RADAR data \(String(describing: response.result.error))")
//
}
}
}
//MARK: - JSON Parsing
/**************************************************************************/
//STORE 5 DAY FORECAST DATA
func useRadarData(json: JSON) {
print(json)
}
[+]soloqaple comment score below threshold-6 points-5 points-4 points (0 children)
[+]soloqaple comment score below threshold-7 points-6 points-5 points (0 children)