How to add the "you're here" marker in Bing Maps Control

How do you add the "you're here" marker to the Bing Maps control? By telephone, this is represented as a circle squared, and then there is an outer circle representing the accuracy of the location.
It looks like you could do this with pushpin and polgon, but I hope there is an easier / better way.

+5
source share
2 answers

You can use the GeoCoordinateWatcher class, which gives your current location, and then add a simple button. I do not think that pressing a button is a poor choice and / or difficult to use.


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);    
+4
source

, : . : .

​​ , . , , , .

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>

soooo. .

+2

All Articles