我有一个需求,我需要显示特定位置的图钉。 我已经能够添加一个自定义图钉,因为PushPin类现在已经被弃用了。 为其代码如下:Windows Phone应用程序8.1的图钉类似于Windows地图应用程序
var location= new Geopoint(new BasicGeoposition() { Latitude = 19.4034, Longitude = 73.8312 });
var pin= CreatePin();
mapper.Children.Add(pin);
MapControl.SetLocation(pin, location);
MapControl.SetNormalizedAnchorPoint(pin, new Point(0.0, 1.0));
mapper.TrySetViewAsync(location, 16, 0, 0, MapAnimationKind.Bow);
代码自定义CreatePin是:
private DependencyObject CreatePin()
{
//Creating a Grid element.
var myGrid = new Grid();
myGrid.RowDefinitions.Add(new RowDefinition());
myGrid.RowDefinitions.Add(new RowDefinition());
myGrid.Background = new SolidColorBrush(Colors.Transparent);
//Creating a Rectangle
var myRectangle = new Rectangle {Fill = new SolidColorBrush(Colors.Black), Height = 20, Width = 20};
myRectangle.SetValue(Grid.RowProperty, 0);
myRectangle.SetValue(Grid.ColumnProperty, 0);
//Adding the Rectangle to the Grid
myGrid.Children.Add(myRectangle);
//Creating a Polygon
var myPolygon = new Polygon()
{
Points = new PointCollection() {new Point(2, 0), new Point(22, 0), new Point(2, 40)},
Stroke = new SolidColorBrush(Colors.Black),
Fill = new SolidColorBrush(Colors.Black)
};
myPolygon.SetValue(Grid.RowProperty, 1);
myPolygon.SetValue(Grid.ColumnProperty, 0);
//Adding the Polygon to the Grid
myGrid.Children.Add(myPolygon);
return myGrid;
}
我现在能够显示自定义脚却无法显示title.Is有办法我可以实现销如同在Windows地图应用程序中使用
我得到什么现在:
我想要什么:
事情是this.Or如果这是不可能添加标题销的方式。 请不要建议MapIcon因为我已经尝试过了,它不现身mapicon除非放大,还我发现它不太可靠
的MapIcon不保证显示。当它遮挡地图上的其他元素或标签时可能会隐藏。
MapIcon的可选标题不保证显示。如果看不到文字,请通过减小MapControl的ZoomLevel属性的值来缩小。
当您显示指向地图上特定位置的MapIcon图像(例如,图钉或箭头)时,请考虑将NormalizedAnchorPoint属性的值设置为图像上指针的大致位置。如果将NormalizedAnchorPoint的值保留为代表图像左上角的默认值(0,0),则地图的ZoomLevel中的更改可能会使图像指向其他位置。
这是好的,如果你想效仿旧形式的推针,但新的API与[MapIcons](https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn792121.aspx)似乎是一个更好的选择 – Petesh
我尝试过使用这个代码MapIcon MapIcon1 = new MapIcon(); MapIcon1.Location = new Geopoint(startLocation); MapIcon1.NormalizedAnchorPoint = new Point(0.5,0.5); MapIcon1.Title =“太空针”; mapper.MapElements.Add(MapIcon1);然而,该图标不会购物,直到放大很多 – Pranjal