Hello Experts,
I'm using Objective c based application. We have implemented a frame to show the map view. The map is getting loaded, however it shows in dark grey color. Could someone please help me on changing to white color?
and i have written like this, still not working. any idea?
Thanks,
Ajitesh
Solved! Go to Solution.
It's important to understand the difference between the backgroundColor of a view, vs the backgroundColor of a map.
A view, like all other UIViews, is that wireframe in the storyboard, or the object that we initialize in code to draw things in it. AGSMapView is no different, so when you set the background color of it, it is the color behind all the content that it renders. Most UIViews have .clear backgroundColor, so you can see through a view when they overlaps.
A map, on the other hand, is the content that a map view renders. It can be as simple as a basemap, or as complex as thousands of feature, graphics, layers, etc. If you set the backgroundColor on a map, it would actually be the color behind all map content.
The map is getting loaded, however it shows in dark grey color.
The gray color you are seeing is the default color for a map. It is actually gray with grid lines, if you see close enough. Below is the code to show a map with road labels only and a white background. You can also set other basemap styles if you want.
import UIKit
import ArcGIS
class ViewController: UIViewController {
@IBOutlet var mapView: AGSMapView! {
didSet {
let map = AGSMap(basemapStyle: .arcGISDarkGrayLabels)
map.backgroundColor = .white
mapView.map = map
mapView.setViewpointCenter(AGSPointMakeWGS84(34.05, -117.17), scale: 1e3)
}
}
}
Please let me know if you have other questions.
It's important to understand the difference between the backgroundColor of a view, vs the backgroundColor of a map.
A view, like all other UIViews, is that wireframe in the storyboard, or the object that we initialize in code to draw things in it. AGSMapView is no different, so when you set the background color of it, it is the color behind all the content that it renders. Most UIViews have .clear backgroundColor, so you can see through a view when they overlaps.
A map, on the other hand, is the content that a map view renders. It can be as simple as a basemap, or as complex as thousands of feature, graphics, layers, etc. If you set the backgroundColor on a map, it would actually be the color behind all map content.
The map is getting loaded, however it shows in dark grey color.
The gray color you are seeing is the default color for a map. It is actually gray with grid lines, if you see close enough. Below is the code to show a map with road labels only and a white background. You can also set other basemap styles if you want.
import UIKit
import ArcGIS
class ViewController: UIViewController {
@IBOutlet var mapView: AGSMapView! {
didSet {
let map = AGSMap(basemapStyle: .arcGISDarkGrayLabels)
map.backgroundColor = .white
mapView.map = map
mapView.setViewpointCenter(AGSPointMakeWGS84(34.05, -117.17), scale: 1e3)
}
}
}
Please let me know if you have other questions.
This worked. Many many thanks for the quick help.