Basemap is not loading - MFC (C++)

578
7
07-01-2022 07:57 AM
mallynaihabi
New Contributor

I am trying to load a basemap in Map control in a MFC (C++) view. The view will host the .NET control (which in C#).

I’m using interop and C++/CLI between C++ and .NET.

I will see the following:

 

mallynaihabi_4-1656686488539.png

 

As you can see, that Powered by Esri get display but the map itself is blank/transparent.

Here is the code that I use to created/load the basemap:

mallynaihabi_1-1656686406986.png

 

I also have a code which set the Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.ApiKey.

I also update the background color but still only display the background of the view.

Here is the code for Map control:

mallynaihabi_2-1656686427711.pngmallynaihabi_3-1656686435398.png

 

The view have other .NET controls and will display that.

I can see the basemap in the map in separate solution inside a MFC view.

I also see the following in debugger (after Map is created and the view is created) which I will not see in other solution:

 
mallynaihabi_17-1656686996043.png

 

Any insight will be very appreciated.

 

Thanks,

Mallyna

 
 

 

 

 

 

 

 

 

 

 

 

 

0 Kudos
7 Replies
dotMorten_esri
Esri Notable Contributor

Looks like there's an issue with communicating with ArcGIS Online. Are you able to load the basemap in a .NET application, without using MFC? Which version of the API and .NET are you using, and what operating system are you using? If any of those are really old, you might just be using a component that doesn't support TLS1.2+

0 Kudos
mallynaihabi
New Contributor

yes. i can load the basemap in .NET application without using MFC. The application is using .NET Framework 4.7.2 and Win 10.  I have a small MFC application that can load the basemap on the same machine and that application also targeting .NET Framework 4.7.2.

0 Kudos
dotMorten_esri
Esri Notable Contributor

Would you be able to create a small sample visual studio project that reproduces the issue and share it?

0 Kudos
dotMorten_esri
Esri Notable Contributor

I'm not sure why your MFC app is running with only TLS1.0 enabled, but if you add this line of code before using the runtime, it should work:


ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

0 Kudos
mallynaihabi
New Contributor

I can load the basemap now.  Thank you!!

I have another quick question.

In the ESRI demo to add a point, line and polygon which will load a basemap then will add a point, line and poygon.  if the basemap is not loaded why can't i see the point, line and polygon? 

0 Kudos
dotMorten_esri
Esri Notable Contributor

You must have a map with an extent and spatial reference established, or overlays won't render.
You can create an empty map and set the SpatialReference in the constructor, and an InitialViewpoint to an extent, and it should show.

0 Kudos
mallynaihabi
New Contributor

I figure it out. 

0 Kudos