【问题标题】:How do you add the "you are here" marker to Bing Maps Control如何将“你在这里”标记添加到 Bing Maps Control
【发布时间】:2011-08-01 15:37:05
【问题描述】:

如何将“你在这里”标记添加到 Bing 地图控件?在手机上,这表示为正方形内的圆圈,然后有一个表示位置精度的外圆。
看起来你可以用图钉和 polgon 做到这一点,但我希望有一种更简单/更好的方法

【问题讨论】:

    标签: bing-maps windows-phone


    【解决方案1】:

    您可以使用提供当前位置的 GeoCoordinateWatcher 类,然后添加一个简单的图钉。我不认为图钉是一个糟糕的选择和/或很难使用。

    
    GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
    
    GeoCoordinate loc = watcher.Position.Location;
    
    if (loc.IsUnknown == true)
    {
        // Cannot retrieve the GPS position
        return;
    }
    
    MyBingMap.SetView(loc, 17);
    
    MapLayer pushPinLayer = new MapLayer();
    
    MyBingMap.Children.Add(pushPinLayer);
    
    Pushpin p = new Pushpin();
    
    p.Content = "YOU ARE HERE";
    p.Location = loc;
    
    pushPinLayer.AddChild(p, loc, PositionOrigin.BottomLeft);    
    

    【讨论】:

      【解决方案2】:

      您问了两个问题,Tuco 给了您一个很好的答案:如何添加图钉。这是第二个问题的答案:如何设置样式。

      要使图钉看起来像黑色菱形中的黄点和白色光环,您需要定义此样式并将其应用于图钉。我还可以告诉你如何用白色光环为中心的黑色圆圈设置白色数字的样式,但那样我就不得不杀了你。

      xmlns:m="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
      
      <Style x:Key="CurrentLocationPushpinStyle" TargetType="m:Pushpin">
        <Setter Property="BorderBrush" Value="#FFF4F4F5" />
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate>
              <Grid>
                <Rectangle Fill="Black" Height="25" Stroke="White" StrokeThickness="2" Width="25" RenderTransformOrigin="0.5,0.5">
                  <Rectangle.RenderTransform>
                    <CompositeTransform Rotation="45" TranslateX="-10" TranslateY="11"/>
                  </Rectangle.RenderTransform>
                </Rectangle>
                <Ellipse Fill="Yellow" Height="11" Stroke="Yellow" Width="11">
                  <Ellipse.RenderTransform>
                    <CompositeTransform TranslateX="-10" TranslateY="11"/>
                  </Ellipse.RenderTransform>
                </Ellipse>
              </Grid>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>
      

      去年的黄点太棒了。芒果使用蓝点。

      【讨论】:

      • 谢谢,我认为它使用了一个点,即你的主题的颜色我目前是绿色的
      • 绿点是 Mango beta 2。我现在有绿点,但我使用蓝色主题。
      猜你喜欢
      • 2016-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-28
      • 1970-01-01
      • 1970-01-01
      • 2017-11-17
      • 1970-01-01
      相关资源
      最近更新 更多