AnsweredAssumed Answered

FeatureLayer.SetDefinition Broken?

Question asked by kirkktx on Feb 21, 2017
Latest reply on Feb 23, 2017 by kirkktx

I would expect the following code to essentially clone the top layer in the map.  It does create a new featurelayer that points to the Uri, but calling SetDefinition has no discernible effect.



private void Test()
    var def = MapView.Active.Map.Layers[0].GetDefinition() as CIMFeatureLayer;
    var conn = def.FeatureTable.DataConnection as CIMStandardDataConnection;
    var folder = conn.WorkspaceConnectionString.Split('=')[1];
    if (conn.WorkspaceFactory != WorkspaceFactory.Shapefile)
        throw new Exception("test only works with shapefile layers");
    var url = Path.Combine(folder, conn.Dataset + ".shp");
    var fLayer = LayerFactory.CreateFeatureLayer(new Uri(url), MapView.Active.Map, 1);
    fLayer.SetName("my layer");
    // name remains "my layer" Setdefinition has no discernible effect