Hi,
In the latest ArcGIS maps SDK release 2.1 I am having issues loading in custom elevation data and IntegratedMesh data through C# API. It worked in prior 1.* without an issue so there seems to be a problem in the latest release. I use the following code:
Map is created as follows which is called in start:
private void CreateArcGisMapComponent()
{
GameObject go = new GameObject("ArcGISMap");
_mapComp = go.AddComponent<ArcGISMapComponent>();
_mapComp.transform.SetParent(transform, false);
_mapComp.OriginPosition = new ArcGISPoint(Origin.Longitude, Origin.Latitude, Origin.Altitude, ArcGISSpatialReference.WGS84());
_mapComp.MeshCollidersEnabled = _enableMeshColliders;
_mapComp.MapType = _mapType;
_mapComp.MapTypeChanged += new ArcGISMapComponent.MapTypeChangedEventHandler(() => CreateArcGISMap());
GameObject rebaseObject = new GameObject("Rebase Component");
rebaseObject.transform.SetParent(go.transform, false);
_rebaseComponent = rebaseObject.AddComponent<CustomRebaseComponent>();
if (ApplicationBootstrapper.Instance.IsDebugEnabled(typeof(TerrainManagerHostService)))
{
ArcGISViewStateLoggingComponent logger = _mapComp.gameObject.GetComponent<ArcGISViewStateLoggingComponent>();
if (logger == null)
{
_mapComp.gameObject.AddComponent<ArcGISViewStateLoggingComponent>();
}
}
}
private uint CreateArcGISMap()
{
uint result = Res.OK;
List<TerrainDefinition> definitions = _parser.GetDefinitions().ToList();
var map = new ArcGISMap(_mapComp.MapType);
var elevationLayers = new ArcGISCollection<ArcGISElevationSource>();
var layers = new ArcGISCollection<ArcGISLayer>();
foreach (TerrainDefinition definition in definitions)
{
result = ValidateConditions(definition, out ArcGISMapLayer layer, out TerrainSource source);
if (Res.CheckCallFailed(result))
{
break;
}
string uri = source.Uri.IsFile ? source.Uri.LocalPath : source.Uri.ToString();
if (layer.Type == ArcGISSourceType.Basemap)
{
if (!string.IsNullOrEmpty(map.Basemap.Source))
{
LOG.Error("A basemap has already been added, multiple basemaps are not supported!");
result = RES.E_SERVICE_INVALID_STATE;
break;
}
if (layer.LayerSourceType == ArcGISLayerType.ArcGISImageLayer)
{
map.Basemap = new ArcGISBasemap(uri, ArcGISLayerType.ArcGISImageLayer, "");
}
else if (layer.LayerSourceType == ArcGISLayerType.ArcGISVectorTileLayer)
{
map.Basemap = new ArcGISBasemap(uri, ArcGISLayerType.ArcGISVectorTileLayer, "");
}
else
{
map.Basemap = new ArcGISBasemap(uri, "");
}
LOG.Debug($"Added Basemap {Enum.GetName(typeof(ArcGISLayerType), _mapComp.BasemapType)} from URL: \"{uri}\"");
}
else if (layer.Type == ArcGISSourceType.Elevation)
{
var elevation = new ArcGISElevationSource(uri, ArcGISElevationSourceType.ArcGISImageElevationSource, "");
elevationLayers.Add(elevation);
LOG.Debug($"Added Elevation layer from URL: \"{uri}\"");
}
else
{
layers.Add(new ArcGISLayer(uri, layer.LayerSourceType, ""));
LOG.Debug($"Added {Enum.GetName(typeof(ArcGISLayerType), layer.LayerSourceType)} from URL: \"{uri}\"");
}
}
if (Res.CheckCallFailed(result))
{
return result;
}
if (string.IsNullOrEmpty(map.Basemap.Source))
{
LOG.Warn("Missing basemap, creating an empty basemap");
_mapComp.Map = new ArcGISMap(ArcGISSpatialReference.WGS84(), _mapType);
}
else
{
map.Elevation = new ArcGISMapElevation(elevationLayers);
}
map.Layers = layers;
_mapComp.View.Map = map;
_mapComp.Map.LoadStatusChanged += OnMapStatusChanged;
_mapComp.View.SpatialReferenceChanged += OnSpatialReferenceChanged;
return result;
}And if i get it to load, my integrated mesh data can look like this and I need to move the camera around to get it to load:
Also, another issue which bothers me is that when I update the map through C# script, these changes does not update the MapComponent in the editor.
If i instead for example add the elevation source like this, it loads. So something funky is going on and it may be seperated from the issue I have with Integrated Mesh layer that in 2.1 sometimes does not render depending on angle of camera. If I downgrade to 2.0 and use the below code, everything works for me.
var temp = new ArcGISElevationSourceInstanceData
{
Source = uri,
AuthenticationType = Esri.ArcGISMapsSDK.Authentication.ArcGISAuthenticationType.None,
IsEnabled = true,
Type = ArcGISElevationSourceType.ArcGISImageElevationSource,
Name = layer.Name
};
_mapComp.MapElevation.ElevationSources.Add(temp);
map.Elevation.ElevationSources.Add(new ArcGISImageElevationSource(uri, layer.Name, ""));For some reason when I load an elevation layer from an offline file I need to add it to elevationsources here meanwhile if i use a elevation source from an Enterprise/ArcGIS online server I need to add it to the map.