【发布时间】:2016-01-10 04:56:20
【问题描述】:
我将图像转换为 base64 字符串并保存到 SQLite 数据库。我想在地图中显示该图像。
用于将字符串转换为图像的代码
public static BitmapImage Base64StringToBitmap(string source)
{
var ims = new InMemoryRandomAccessStream();
var bytes = Convert.FromBase64String(source);
var dataWriter = new DataWriter(ims);
dataWriter.WriteBytes(bytes);
dataWriter.StoreAsync();
ims.Seek(0);
var img = new BitmapImage();
img.SetSource(ims);
return img;
}
如何在地图中显示此图像。显示图钉
private void loadPushpin(object sender, RoutedEventArgs e)
{
using (var dbConn = new SQLiteConnection(App.DB_PATH))
{
var query = dbConn.Table<Contacts>();
var result = query.ToList();
foreach (var item in result)
{
Contacts obj = new Contacts();
MapIcon MapIcon1 = new MapIcon();
MapIcon1.Image = RandomAccessStreamReference.CreateFromUri(new Uri(""));
MapIcon1.Location = new Geopoint(new BasicGeoposition()
{
Latitude = Convert.ToDouble(item.Latitude),
Longitude = Convert.ToDouble(item.Longitude)
});
MapIcon1.NormalizedAnchorPoint = new Point(0.5, 1.0);
MapIcon1.Title = item.Name;
MyLocationMap.MapElements.Add(MapIcon1);
}
}
}
【问题讨论】:
标签: c# geolocation windows-phone-8.1