c# - ArgumentException when adding many coordinates on the map -
i add pushpins can clickable on map. first, display them when add them on map, argumentexception occured , application crashes. if add 1 place on map, works when i'm trying add more places, crashes. whole list has been traversed.
my code:
var mycircle = new ellipse { fill = new solidcolorbrush(colors.blue), height = 20, width = 20, opacity = 50 }; maplayer locationlayer = new maplayer(); foreach (var place in r.result) { //it's method created placecoordinate in format because can commas var placecoordinate = geolocalisation.getcoordinateingoodformat(place.google_lat, place.google_lng); if (placecoordinate == null) { continue; } var locationoverlay = new mapoverlay { content = mycircle, positionorigin = new point(0.5, 0.5), geocoordinate = placecoordinate }; debug.writeline(place.title + ", lat: " + place.google_lat + ", long: " + place.google_lng); //display e.g.: soleil du midi, lat: 50.8382836, long: 4.3975321 locationlayer.add(locationoverlay); } mapcontrol.layers.add(locationlayer); //my map in xaml
the error :
an exception of type 'system.argumentexception' occurred in system.windows.ni.dll , wasn't handled before managed/native boundary
i have tried creating new instance of circle every point on map because can't add same uielement (in case circle) visual tree twice.
var locationoverlay = new mapoverlay { content = new ellipse() { fill = new solidcolorbrush(colors.blue), height = 20, width = 20, opacity = 50 }, positionorigin = new point(0.5, 0.5), geocoordinate = placecoordinate };
Comments
Post a Comment