My 1 Service have only 1 layer with year wise archive data. Like it have same geometries at different year along with some addon in another year.
I want to use this Dynamic layer for representing the geoms on map yearwise with different symbols [Polyline] when user choose year. I m using MVVM Light, Silverlight. I do what ever but not able to change the rendering of Layer.
I crate ArcGISDynamicMapServiceLayer
when User click on check box and create the layer. Then add to LayersCollection
. once it initialize then I add Rendere. But still no hope. Can any one help me?
public void ProjectLayer(ref HpmsMapLayerModel lyr, ref HpmsBaseEsriMapViewModel baseVm,bool isDynamic)
{
currentProjection = null;
currentProjection = lyr;
BaseVm = baseVm;
ArcGISDynamicMapServiceLayer mapLayer = new ArcGISDynamicMapServiceLayer();
mapLayer.Url = lyr.Url;
mapLayer.ID = lyr.Id;
mapLayer.DisableClientCaching = true;
LayerInfo linf = new LayerInfo();
linf.ID = 0;
linf.SubLayerIds = new int[]{0};
linf.DefaultVisibility = false;
DynamicLayerInfoCollection dyLyInfColx= mapLayer.CreateDynamicLayerInfosFromLayerInfos();
dyLyInfColx = new DynamicLayerInfoCollection();
BaseMapVM.Layers.Add(mapLayer);
mapLayer.Initialized+=mapLayer_Initialized;
GetFeatures("HPMSYEAR='" + 2013 + "'", lyr, baseVm);
}
private void mapLayer_Initialized(object sender, EventArgs e)
{
var rlyr = sender as ArcGISDynamicMapServiceLayer;
var lyr = BaseMapVM.Layers.Where(L => L.ID == rlyr.ID).FirstOrDefault() as ArcGISDynamicMapServiceLayer;
lyr.Layers[0].DefaultVisibility = false;
DynamicLayerInfo layer1 = new DynamicLayerInfo();
layer1.ID = 0;
LayerMapSource lms = new LayerMapSource();
lms.MapLayerID = 4;
layer1.Source = lms;
DynamicLayerInfoCollection dyLyInfColx = lyr.CreateDynamicLayerInfosFromLayerInfos();
dyLyInfColx.Add(layer1);
lyr.DynamicLayerInfos = dyLyInfColx;
LayerDefinition ldef = new LayerDefinition();
ldef.LayerID = 0;
string whereClse = "HPMSYEAR='" +2013+"'";
ldef.Definition = whereClse;
ObservableCollection<LayerDefinition> layerDrfins = new ObservableCollection<LayerDefinition>();
layerDrfins.Add(ldef);
lyr.LayerDefinitions = layerDrfins;
LayerDrawingOptions ldrOpns = new LayerDrawingOptions();
ldrOpns.LayerID = 0;
UniqueValueRenderer myUniqueValueRenderer = new UniqueValueRenderer();
myUniqueValueRenderer.Field = "HPMSYEAR";
UniqueValueInfo myUniqueValueInfo1 = new UniqueValueInfo();
myUniqueValueInfo1.Value = 2013;
//SimpleFillSymbol mySimpleFillSymbol1 =
// new SimpleFillSymbol();
SimpleLineSymbol smp = new SimpleLineSymbol();
smp.Color = BrushConstants.Green; // BrushConstants.DefaultBrushes[colorIndex];
smp.Width = 5;
myUniqueValueInfo1.Symbol = smp;
myUniqueValueRenderer.Infos.Add(myUniqueValueInfo1);
ldrOpns.Renderer = myUniqueValueRenderer;
LayerDrawingOptionsCollection ldoc = new LayerDrawingOptionsCollection();
ldoc.Add(ldrOpns);
lyr.LayerDrawingOptions = ldoc;
ArcGISDynamicMapServiceLayer rLyr = null;
rLyr = BaseMapVM.Layers.Where(L => L.ID == lyr.ID).FirstOrDefault() as ArcGISDynamicMapServiceLayer;
if (rLyr != null)
{
// BaseMapVM.Layers.Remove(rLyr);
// BaseMapVM.Layers.Add(lyr);
lyr.Refresh();
}
var b = e;
}
When User Click on Check Box HpmsMapLayerModel
class contains the URL, Name, Id etc information and I HpmsBaseEsriMapViewModel
contains the Map Object etc.
What I m doing wrong. I m not able to figure out. All the time layer get loaded with full data. Along with predefined rendere which is of Pink Color.