【发布时间】:2017-01-29 20:08:42
【问题描述】:
出于个人需要,对于Xamarin.Forms.Map控件,我需要创建一个CustomPin扩展。 UWP 部分(PCL 项目)
我创建了一个MapIcon 喜欢它:
nativeMap.MapElements.Add(new MapIcon()
{
Title = pin.Name,
Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Pin/customicon.png")),
Location = new Geopoint(new BasicGeoposition() { Latitude = pin.Position.Latitude, Longitude = pin.Position.Longitude }),
NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0)
});
但是,通过这种方式,我无法设置Image 的大小。
然后我想使用我的 PCL 部分中的 Image,调整它的大小并将其转换为 IRandomAccessStreamReference。为了实现它,我需要将我的Image 转换为流,但我找不到让它工作的方法>
所需函数示例:
private IRandomAccessStreamReference ImageToIRandomAccessStreamReference(Image image)
{
//Here I can set the size of my Image
//I convert it into a stream
IRandomAccessStreamReference irasr = RandomAccessStreamReference.CreateFromStream(/* img? */);
//irasr is then created from img
//I return the IRandomAccessStreamReference needed by the MapIcon element
return irasr;
}
注意:Image 参数 img 是 Xamarin.Forms.Image
首先,这可能吗?如果是的话,那么感谢任何可以帮助我的帮助。我已经搜索了如何调整 MapIcon 的大小,但无法直接从类 [MapIcon] 中进行调整。(https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.maps.mapicon.aspx)
感谢您的帮助!
【问题讨论】:
标签: xamarin.forms uwp bing-maps marker uwp-maps