我正在尝试绘制不同形状的圆圈但无论我输入的半径是创建一个固定大小半径(50mt)的圆圈......任何人都可以帮助我这里是我的代码
//_accuracy=0.0; double radius=0.0;
double metersPerPixels = (Math.Cos(geo.Latitude * Math.PI / 180) * 2 * Math.PI * 6378137) / (256 * Math.Pow(2, MyMap.ZoomLevel));
radius = _accuracy / metersPerPixels;
Ellipse ellipse = new Ellipse();
ellipse.Width = radius * 2;
ellipse.Height = radius * 2;
ellipse.Fill = new SolidColorBrush(Color.FromArgb(75, 200, 0, 0));
MapOverlay overlay = new MapOverlay();
overlay.Content = ellipse;
overlay.GeoCoordinate = new GeoCoordinate(geo.Latitude, geo.Longitude);
overlay.PositionOrigin = new Point(0.5, 0.5);
mapLayer.Add(overlay);
答案 0 :(得分:0)
此代码适用于创建固定大小的圆圈。要使它成为动态的,您需要使用ZoomLevelChanged回调:
//where myMap is defined
myMap.ZoomLevelChanged += myMapZoomLevelChanged;
//somewhere else in the code
private void myMapZoomLevelChanged(MapControl sender, object args) {
for (int i = 0; i < circlesOnMap.Count; i++)
{
double metersPerPixel = (Math.Cos(geo.Position.Latitude * Math.PI / 180) * 2 * Math.PI * 6378137) / (256 * Math.Pow(2, myMap.ZoomLevel));
ellipse.Height = radiusInMeters / metersPerPixel * 2;
ellipse.Width = radiusInMeters / metersPerPixel * 2;
}
}