我想添加一些可以在地图上点击的图钉。首先,我想显示它们,但是当我将它们添加到地图上时,会发生 ArgumentException 并且我的应用程序崩溃了。如果我在地图上只添加一个地方,它可以工作,但是当我尝试添加更多地方时,它会崩溃。整个列表都被遍历了。
我的代码:
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 a method that I created to get the placecoordinate in good format because it can be with 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
错误 :
An exception of type 'System.ArgumentException' occurred in System.Windows.ni.dll and wasn't handled before a managed/native boundary