Map Your Apps: Listing 1.

Code that places a marker dot on a map.

.private void PlaceDot(Location locati
on, Color color)
  Ellipse dot = new Ellipse();
  dot.Fill = new SolidColorBrush(color);
  double radius = 12.0;
  dot.Width = radius * 2;
  dot.Height = radius * 2;
  ToolTip tt = new ToolTip();
  tt.Content = "Location = " + location;
  dot.ToolTip = tt;
  Point p0 = myMap.LocationToViewportPoint(location);
  Point p1 = new Point(p0.X - radius, p0.Y - radius);
  Location loc = myMap.ViewportPointToLocation(p1);
  MapLayer.SetPosition(dot, loc);

About the Author

Dr. James McCaffrey works for Microsoft Research in Redmond, Wash. He has worked on several Microsoft products including Azure and Bing. James can be reached at [email protected].

comments powered by Disqus


Subscribe on YouTube