WP7地图控件的图钉尺寸

时间:2012-04-30 11:29:59

标签: windows-phone-7 map pushpin

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

<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像素的椭圆?

Screenshot with this behavior

谢谢!

1 个答案:

答案 0 :(得分: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,在我的地图位置示例中。祝你好运!