Select to view content in your preferred language

how to export google satellite map as tpkx in c#?

139
0
08-15-2024 07:46 PM
Penny09010901
New Contributor

We have one requirement to show google satellite map in our solution. It works for online scenario by using below code:

appState.setUsingOnlineMap(true);
WebTiledLayer webTiledLayer = new WebTiledLayer("https://mt1.google.com/vt/lyrs=y&x={col}&y={row}&z={level}");
Map = new Map(BasemapStyle.OSMDarkGray);
Map.OperationalLayers.Add(webTiledLayer);
While if we try to save such google satellite map as tpkx file, used for offline. Then it will failed by some error(Response status code does not indicate success: 400 (Bad Request).).

//private Uri _serviceUri = new Uri("https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer");
private Uri _serviceUri = new Uri("https://mt1.google.com/vt/lyrs=y&x={col}&y={row}&z={level}");
// Create the tile layer.
ArcGISTiledLayer mapLayer = new ArcGISTiledLayer(_serviceUri);

// Load the layer.
await mapLayer.LoadAsync(); //Error happens here,but if _serviceUri changes to arcgis link, then error is gone

Map mainMap = new Map(new Basemap(mapLayer))
{
MaxScale = 70.53,
MinScale = 144447.64
};

// Create a new ExportTileCacheParameters instance.
ExportTileCacheParameters parameters = new ExportTileCacheParameters();

// Set the area for the export.
parameters.AreaOfInterest = offlineArea;

// Set the highest possible export quality.
parameters.CompressionQuality = 100;

for (int x = 11; x <= 19; x++)
{
parameters.LevelIds.Add(x);
}
int num = 2;
string offlinePath = Path.Combine(offlineMapDirectory, $"{fileName}.tpkx");

I also tried to import google satellite map as basemap in arcGIS, it also works. But in such case, the download map button is DISABLE, so can NOT save such google map basemap layer as tpkx in arcGIS pro.
My question is:
1) is it possible to save google satellite map layer as tpkx file in arcGIS pro or by code?
2) how to implement it?
Thanks,

0 Kudos
0 Replies