mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 06:26:41 +00:00
Version 4.12.2 Fixed local file handling for UWP. All relative paths relative to ms-appx:
This commit is contained in:
parent
26bf0b5005
commit
c28387f87c
14 changed files with 172 additions and 192 deletions
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
|
|
@ -21,28 +20,21 @@ namespace MapControl.Images
|
|||
UseLayoutRounding = false;
|
||||
}
|
||||
|
||||
private async Task<List<ImageOverlay>> ReadGroundOverlaysFromFile(string docFile)
|
||||
private async Task<IEnumerable<ImageOverlay>> ReadGroundOverlaysFromFile(string docFile)
|
||||
{
|
||||
if (!Path.IsPathRooted(docFile))
|
||||
docFile = Path.GetFullPath(docFile);
|
||||
|
||||
var file = await StorageFile.GetFileFromPathAsync(docFile);
|
||||
var kmlDocument = new XmlDocument();
|
||||
|
||||
using (var stream = await file.OpenReadAsync())
|
||||
{
|
||||
docFile = Path.Combine(Directory.GetCurrentDirectory(), docFile);
|
||||
kmlDocument.Load(stream.AsStreamForRead());
|
||||
}
|
||||
|
||||
var imageOverlays = ReadGroundOverlays(kmlDocument).ToList();
|
||||
var docUri = new Uri(docFile);
|
||||
|
||||
var imageOverlays = await Task.Run(async () =>
|
||||
{
|
||||
var file = await StorageFile.GetFileFromPathAsync(docFile);
|
||||
var kmlDocument = new XmlDocument();
|
||||
|
||||
using (var stream = await file.OpenReadAsync())
|
||||
{
|
||||
kmlDocument.Load(stream.AsStreamForRead());
|
||||
}
|
||||
|
||||
return ReadGroundOverlays(kmlDocument).ToList();
|
||||
});
|
||||
|
||||
foreach (var imageOverlay in imageOverlays)
|
||||
{
|
||||
imageOverlay.ImageSource = await ImageLoader.LoadImageAsync(new Uri(docUri, imageOverlay.ImagePath));
|
||||
|
|
@ -51,7 +43,7 @@ namespace MapControl.Images
|
|||
return imageOverlays;
|
||||
}
|
||||
|
||||
private async Task<List<ImageOverlay>> ReadGroundOverlaysFromArchive(string archiveFile)
|
||||
private async Task<IEnumerable<ImageOverlay>> ReadGroundOverlaysFromArchive(string archiveFile)
|
||||
{
|
||||
using (var archive = ZipFile.OpenRead(archiveFile))
|
||||
{
|
||||
|
|
@ -63,17 +55,14 @@ namespace MapControl.Images
|
|||
throw new ArgumentException("No KML entry found in " + archiveFile);
|
||||
}
|
||||
|
||||
var imageOverlays = await Task.Run(() =>
|
||||
var kmlDocument = new XmlDocument();
|
||||
|
||||
using (var docStream = docEntry.Open())
|
||||
{
|
||||
var kmlDocument = new XmlDocument();
|
||||
kmlDocument.Load(docStream);
|
||||
}
|
||||
|
||||
using (var docStream = docEntry.Open())
|
||||
{
|
||||
kmlDocument.Load(docStream);
|
||||
}
|
||||
|
||||
return ReadGroundOverlays(kmlDocument).ToList();
|
||||
});
|
||||
var imageOverlays = ReadGroundOverlays(kmlDocument).ToList();
|
||||
|
||||
foreach (var imageOverlay in imageOverlays)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue