c# - Not all MapIcons get updated on map? -


im adding multiple mapicons uwp app mapcontrol. want change mapicon size based map zoom level.

this works ok, when update marker sizes (call updatmarkersizes()) not mapicons new image.

i have around 200 mapicons in map, try update. performance issue or how should try update mapicons?

here how add mapicons:

public void addmapicons(ireadonlycollection<iitem> items) {     var icon = (currentmarkericonsize == markericonsize.small) ? _markersmall : _markernormal;     foreach (var item in items)     {         var stopicon = new mapicon         {             location = new geopoint(item.location),             normalizedanchorpoint = new point(0.5, 0.5),             zindex = 5,             collisionbehaviordesired = mapelementcollisionbehavior.remainvisible,             image = icon         };         mapcontrol.mapelements.add(stopicon);     } } 

and here mapicon image update functionality, called when map zoomlevel changed.

private void updatmarkersizes(markericonsize newsize) {     var newimage = (newsize == stopiconsize.small) ? _markersmall : _markernormal;     foreach (var element in mapcontrol.mapelements)     {         (element mapicon).image = newimage;     } } 

update 1:

i noticed if update mapicon normalizedanchorpoint, zindex , collisionbehaviordesired (set same value again), issue not bad. when updated markers (updatmarkersizes()) there couple of markers did not new image. after update, 1 or 2 markers did not new image.

updated code:

private void updatmarkersizes(markericonsize newsize) {     var newimage = (newsize == stopiconsize.small) ? _markersmall : _markernormal;     foreach (var element in mapcontrol.mapelements)     {         var mapiconelement = element mapicon;         if(mapiconelement != null)         {             mapiconelement.image = newimage;             mapiconelement.normalizedanchorpoint = new point(0.5, 0.5);             mapiconelement.zindex = 5;             mapiconelement.collisionbehaviordesired = mapelementcollisionbehavior.remainvisible;          }     } } 

update 2: think solution in update 1 enough now. have posted new question related mapicons , image updating too: dynamically update collection of mapicons, update process gets out of sync?


Comments