How to set arcgis custom provider

Hi, in a simple project I’m trying to use arcgis as a basemap, but I can’t display the map. Here’s my code: (https://mapwindow.discourse.group/t/use-arcgis-custom-provider/164/2)

        private void btnLoadBasemap_Click(object sender, EventArgs e)
        {
            axMap1.CursorMode = MapWinGIS.tkCursorMode.cmPan;

            // add definition of custom provider
            int newID = (int)tkTileProvider.ProviderCustom;
            axMap1.Tiles.Providers.Add(newID, "Custom Provider",
                "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{0}/{2}/{1}.jpg",
                tkTileProjection.SphericalMercator, 0, 18);
            // set custom provider as the current provider
            axMap1.Tiles.ProviderId = newID;
            axMap1.Redraw3(tkRedrawType.RedrawSkipAllLayers, true);
        }

I’m trying to use the same basemap called “NASA Satellite imagery via ESRI” available in Easy GIS .NET.

Can anyone help me?

Thank you.

Hello Henry.

As a test, I entered the following URL into my browser to verify I was able to load images from the URL you have in your code, and I am. The following shows a single image of the southern hemisphere.

Are you able to see the same on the machine on which you’re testing?

https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/1/1/1.jpg

Hi Jerry, thanks for the reply.
Yes, I can view the image with the URL you posted.

After countless attempts, here’s the working code, tested on Windows 10 and Microsoft Visual Studio Community 2019:

        private void btnLoadBasemap_Click(object sender, EventArgs e)
        {
            axMap1.CursorMode = MapWinGIS.tkCursorMode.cmPan;

            string strUrl = "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{zoom}/{y}/{x}";

            // add definition of custom provider
            int newID = (int)tkTileProvider.ProviderCustom;
            axMap1.Tiles.Providers.Add(newID, "Custom Provider",
                                       strUrl, tkTileProjection.SphericalMercator);
            // set custom provider as the current provider
            axMap1.Tiles.ProviderId = newID;

            // center the map on Italy
            axMap1.Latitude = 41.9028F;
            axMap1.Longitude = 12.4964F;
            axMap1.CurrentZoom = 6;

            axMap1.Redraw3(tkRedrawType.RedrawSkipAllLayers, true);
        }

I hope this helps someone.

1 Like

Kudos, and I’m sure it will - I may even try it :wink: Thanks for sticking with it and sharing!