我的图像有Uri类型的想象源,我想把它作为我的MapIcon的源,因为我需要调整我的图像大小。
MapIcon mapIcon = new MapIcon();
mapIcon.NormalizedAnchorPoint = new Point(0.25, 0.9);
//mapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/icons/map.png"));
mapIcon.Location = geoposition.Coordinate.Point;
mapIcon.Title = "Você está aqui";
MapControl1.MapElements.Add(mapIcon);
Image im = new Image();
im.Source = new BitmapImage(new Uri("ms-appx:///Assets/icons/view.png"));
im.Width = 65;
im.Height = 65;
如何将我的Image放入MapIcon?谢谢!
答案 0 :(得分:1)
我在这个问题的所有页面中都没有提到....要使用Assets文件夹中的本地文件作为地图图标,你必须将它添加到项目中...在解决方案资源管理器中展开Assets,单击“资源”,单击“添加”,选择“现有项目”,导航到项目的“资产”文件夹,然后选择图像文件。
答案 1 :(得分:-1)
Geopoint myPoint;
BasicGeoposition location = new BasicGeoposition();
var locator = new Geolocator();
locator.DesiredAccuracyInMeters = 50;
var position = await locator.GetGeopositionAsync();
myPoint = position.Coordinate.Point;
MapIcon MapIcon = new MapIcon();
MapIcon.Location = new Geopoint(new BasicGeoposition()
{
Latitude = myPoint.Position.Latitude,
Longitude = myPoint.Position.Longitude
});
MapIcon1.NormalizedAnchorPoint = new Point(0.5, 1.0);
location.Latitude = myPoint.Position.Latitude;
location.Longitude = myPoint.Position.Longitude;
Geopoint pointToReverseGeocode = new Geopoint(location);
MapLocationFinderResult result =
await MapLocationFinder.FindLocationsAtAsync(pointToReverseGeocode);
//MapIcon.Title = result.Locations[0].Address.Street;
MapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/icons/view.png"));
YourMap.MapElements.Add(MapIcon);