1

在尝试实现显示当前用户位置的逻辑时,我遇到了一个问题。

<Maps:Pushpin Location="{Binding MyLocation}" Canvas.ZIndex="1000" PositionOrigin="Center"  >
            <Maps:Pushpin.Template>
                <ControlTemplate>
                    <Grid>
                        <Ellipse Width="{Binding MyAccuracyViewSize}" Height="{Binding MyAccuracyViewSize}"
                                 Fill="#60008000" Stroke="Green" StrokeThickness="3"/>
                        <Ellipse Width="18" Height="18" Fill="#A0FF4500" VerticalAlignment="Center" HorizontalAlignment="Center"  />
                    </Grid>
                </ControlTemplate>
            </Maps:Pushpin.Template>
        </Maps:Pushpin>

较大的绿色圆圈显示准确区域。它的像素大小因缩放而异。如果缩放级别很大 - 它变得相当大(> 480 像素)。那时它会被屏幕分辨率裁剪。AFAIK WP7 的控件大小限制为 2000x2000 像素。

似乎这是一种地图控制限制。

任何想法如何消除此限制以显示最大为 2000x2000 像素的椭圆?

此行为的屏幕截图

谢谢!

4

1 回答 1

2

MapPolygon 怎么样?

void OnPositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
        {
            SecondsCounter = 0; //reset counter
            double accuracy = e.Position.Location.HorizontalAccuracy;
        if (accuracy < e.Position.Location.VerticalAccuracy)
        {
            accuracy = e.Position.Location.VerticalAccuracy;
        }

        if (PolyCircle == null)
        {
            PolyCircle = new MapPolygon();
            PolyCircle.Opacity = 0.7;
            //Set the polygon properties 

            PolyCircle.Fill = new SolidColorBrush(Colors.Orange);
            PolyCircle.Stroke = new SolidColorBrush(Colors.Purple);
            PolyCircle.StrokeThickness = 4;

            map1.Children.Add(PolyCircle);
        }

        PolyCircle.Locations = CreateCircle(e.Position.Location, accuracy);


        map1.Center = e.Position.Location;    

    }

    public static double ToRadian(double degrees)
    {
        return degrees * (Math.PI / 180);
    }

    public static double ToDegrees(double radians)
    {
        return radians * (180 / Math.PI);
    }

    public static LocationCollection CreateCircle(GeoCoordinate center, double radius)
    {
        var earthRadius = 6367000; // radius in meters
        var lat = ToRadian(center.Latitude); //radians
        var lng = ToRadian(center.Longitude); //radians
        var d = radius / earthRadius; // d = angular distance covered on earth's surface
        var locations = new LocationCollection();

        for (var x = 0; x <= 360; x++)
        {
            var brng = ToRadian(x);
            var latRadians = Math.Asin(Math.Sin(lat) * Math.Cos(d) + Math.Cos(lat) * Math.Sin(d) * Math.Cos(brng));
            var lngRadians = lng + Math.Atan2(Math.Sin(brng) * Math.Sin(d) * Math.Cos(lat), Math.Cos(d) - Math.Sin(lat) * Math.Sin(latRadians));

            locations.Add(new GeoCoordinate(ToDegrees(latRadians), ToDegrees(lngRadians)));
        }

        return locations;
    }

更多here,在我的地图位置示例中。祝你好运!

于 2013-04-01T12:38:56.473 回答