Has something changed with licensing / API key? Maps don't show even on sample code

971
4
09-21-2022 11:49 AM
FortressTech
New Contributor

Howdy,

I've been building an app for a few years now and it has been utilizing the older versions of the Windows WPF SDK up until recently. In changing some code in the model view over to use the newer BasemapStyle model, my map shows no detail - only a black screen. 

I've gone as far as downloading the sample apps and tried running the simplest of all and it displays just a white background with "Powered by ESRI" in the lower right corner.

Did ESRI implement a different SDK key/licensing setup?

Old code: (Displays correctly

[Obsolete]
private Map _map = new Map(BasemapType.StreetsNightVector, _defaultLat, _defaultLon, _defaultZoom)
{
MinScale = Configs.MaxZoomOutScale,
MaxScale = Configs.MaxZoomInScale
};

New code: (Shows black screen, nothing else)

_map = new Map(BasemapStyle.ArcGISStreetsNight);

Tags (1)
0 Kudos
4 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

The basemaps in the BasemapStyle Enum are the new developer basemaps. You enable your access to them by creating and managing your developer API keys in your ArcGIS Developer dashboard, or alternatively by authenticating with an ArcGIS Identity. Essentially the services need a token to enable access, that is either in the form of an API Key that you set via the API, or a token that's automatically appended to requests after you enable users to authenticate with their ArcGIS identity.

For more info see:

Release notes for 100.10 | ArcGIS Runtime API for .NET | ArcGIS Developers

API keys | Documentation | ArcGIS Developers

 

Thanks

0 Kudos
FortressTech
New Contributor

Thanks, Michael.

I found that the problem is actually related to *when* the API key is supplied.

In the documentation, it shows supplying the key VERY early in the process (in the App.xaml.cs) whereas my code has always initialized the API after I get my users authenticated in the main body of the app.

If I attempt to feed the API Key once the WPF main form loads (but before displaying the map), I get a black screen as described. 

If I feed the API key right after calling ArcGISRuntimeEnvironment.Initialize(); in App.xaml.cs, the maps will display correctly.

This appears to be a material change in the API registration code as I did not have this issue until upgrading the SDK to this month's latest version. 

Fun. Looks like I will need to refactor spooling up the encryption web service to fetch my API key before the main application body runs and I'm able to authenticate the app's user, which isn't optimal for security reasons.

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

> after I get my users authenticated in the main body of the app

Are your users authenticating as ArcGIS users?  

0 Kudos
FortressTech
New Contributor

Hi Michael,

No. I may go that route at a later date, but currently individual users authenticate over an HTTPS connection to a web service. 

I've tried a couple ideas moving things around, but the issue remains fairly consistent. If I put the Initialization anywhere other than inside the app.xaml.cs class (upon app startup) it produces the black screen effect.

Appears one MUST place the Init and API key in that early chain, otherwise nothing will work. This is really disappointing as it means a LOT of refactoring *just* for that piece.

0 Kudos