Currently I have a map that loads shapefiles, then hits a WCF service to build some symbols based on the data. I have a timer setup to call the wcf which I build the symbols from. It seems to keep adding symbols each time I reload the data. Is there away around that?
some relevant code
DispatcherTimer Dtimer = new DispatcherTimer();
public
MainPage()
{
InitializeComponent();
Dtimer.Interval = new TimeSpan(0, 0, 30);
Dtimer.Tick +=new EventHandler(Dtimer_Tick);
Dtimer.Start();
}
protected void Dtimer_Tick(object s, EventArgs args)
CDBServiceClient Client5 = new CDBServiceClient();
Client5.CustomerServiceListCompleted += new EventHandler<CustomerServiceListCompletedEventArgs>(Client5_CustomerServiceListCompleted);
Client5.CustomerServiceListAsync();
mylabel.Content ="Last Updated:" + DateTime.Now;
private void MapLayer_Imported(object sender, MapLayerImportEventArgs e)
if (e.Action == MapLayerImportAction.End)
Hello,
Thank you for your post. I have been looking into it, but it seems like that I am missing something in your scenario, so could you please send an isolated sample project, where the issue is reproduced, so I can investigate it further for you.
Looking forward for your reply.
Hi,
the other relevant part is the method that adds the symbols. when I call the refresh from the timer, it writes all the symbols again. how can I have it update the exsisting? or remove the exsisting?
void Client5_CustomerServiceListCompleted(object sender, CustomerServiceListCompletedEventArgs
e)
XamMap combo = this.FindName("mymap1") as XamMap
;
double
latitude = 0;
longitude = 0;
foreach (CustomerService b in
e.Result)
latitude =Convert.ToDouble(b.LATITUDE.ToString());
longitude =Convert.ToDouble(b.LONGITUDE.ToString());
// Get Point data using a projection from Geodetic to Cartesian coordinates
Point origin = combo.MapProjection.ProjectToMap(new Point
(longitude, latitude));
MapSymbolType mysymbol = new MapSymbolType
();
Double mysize = new Double
String
mybranch;
mybranch = b.PLNT_CD.Trim().Substring(0, 3);
if
(b.ROUTERQUEUECALLSTO5 > 0)
mysymbol =MapSymbolType.Pyramid;
mysize = b.ROUTERQUEUECALLSTO5 *2;
else
mysize = 0;
SymbolElement element = new SymbolElement() { SymbolOrigin = origin, SymbolType = mysymbol, SymbolSize = mysize };
element.Name = b.PLNT_CD;
SolidColorBrush bc1 = new SolidColorBrush(Colors.Red);
SolidColorBrush bc2 = new SolidColorBrush(Colors.Blue);
SolidColorBrush bc3 = new SolidColorBrush(Colors.Green);
SolidColorBrush bc4 = new SolidColorBrush(Colors.Yellow);
if (b.CLUSTER == "CM1"
)
{ element.Fill = bc1; }
else if (b.CLUSTER == "CM2"
{ element.Fill = bc2; }
else if (b.CLUSTER == "CM3"
{ element.Fill = bc3; }
{ element.Fill = bc4; };
combo.Layers[0].Elements.Add(element);