map is shows dark grey color and expected to show in white

239
3
Jump to solution
04-05-2024 04:57 AM
AjiteshUpadhyaya
New Contributor III

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? 

IMG_BFC2D5ECD328-1.jpeg

 and i have written like this, still not working. any idea?

AjiteshUpadhyaya_0-1712318290657.png

 

 

 

Thanks,

Ajitesh

0 Kudos
1 Solution

Accepted Solutions
Ting
by Esri Contributor
Esri Contributor

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.

View solution in original post

0 Kudos
3 Replies
jswift
by
New Contributor
Hi Ajitesh,
The gray map may be a default grey basemap; you must specify a different Esri basemap to load with the map view, override any default. Also, your screen shot is not high enough resolution for the code to be easily legible in this post - I recommend simply making the screen shots bigger or pasting the code as text into your posts.
Best Jen
Ting
by Esri Contributor
Esri Contributor

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.

0 Kudos
AjiteshUpadhyaya
New Contributor III

This worked. Many many thanks for the quick help.