I'm currently working on creating and adding `AGSWebTiledLayer` tiles to my map. I have a service that returns valid tiles using the following format as described in the documentation:
The problem that I'm coming across is when I add the `AGSWebTiledLayer` to the `operationLayers` of the map, nothing happens.
I also implemented the `urlForTileKeyHandler` handler and returned the url following the format above, but when debugging, that handler is never called.
Is there something else that needs to happen to get the tiles to display? From what I can tell, the layer is being added to the map, but it's never actually fetching the data.
Thanks.
I figured it out. It seems that web tile layers need to be explicitly told to load, a step which I was neglecting to do.
Hmm. This is odd. I am unable to reproduce this in my testing using openweatherdata.org tiles…
Which version of Runtime are you using?
In case anyone's interested, here's the code I used to try to test:
import UIKit
import ArcGIS
let apiKey = "GET ONE FROM OPENWEATHERDATA.ORG - FREE ACCOUNT REQUIRED"
let layerNames = ["clouds_new", "temp_new", "precipitation_new"]
class ViewController: UIViewController {
@IBOutlet weak var mapView: AGSMapView!
var tiledLayers: [AGSWebTiledLayer]? = nil
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let map = AGSMap(basemap: AGSBasemap.streetsVector())
mapView.map = map
let layers = layerNames.map({ layerName -> AGSWebTiledLayer in
let urlTemplate = "https://tile.openweathermap.org/map/\(layerName)/{level}/{col}/{row}.png?appid=\(apiKey)"
let layer = AGSWebTiledLayer(urlTemplate: urlTemplate)
layer.opacity = 1.0
layer.isVisible = false
// if let rc = AGSRequestConfiguration.global().copy() as? AGSRequestConfiguration {
// rc.debugLogResponses = true
// layer.requestConfiguration = rc
// }
return layer
})
map.operationalLayers.addObjects(from: layers)
tiledLayers = layers
tiledLayers?.first?.isVisible = true
mapView.touchDelegate = self
}
}
extension ViewController: AGSGeoViewTouchDelegate {
func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
guard let layers = mapView.map?.operationalLayers as? [AGSLayer] else { fatalError("Layers are not layers!") }
guard let firstLayer = layers.first else { return }
let newVisible = !firstLayer.isVisible
layers.forEach {
$0.isVisible = newVisible
}
}
}
Hi Robert Koch, do you still need to load your layer before it'll work? I wasn't able to reproduce this behavior but am keen to understand if there's some case that triggers it which we haven't considered and need to fix.
Hey Nicholas Furness, I haven't had a chance to look through this with the holidays and all. I actually haven't revisited it since loading the layers is working. If I get time to go back and revisit it, I'll check out your code above and let you know.