mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
GeoImage and GroundOverlay implementation
This commit is contained in:
parent
febb6d6b00
commit
b22ee9a60f
5 changed files with 25 additions and 38 deletions
|
|
@ -33,15 +33,18 @@ namespace MapControl
|
|||
{
|
||||
public static partial class GeoImage
|
||||
{
|
||||
private partial class GeoBitmap
|
||||
private class GeoBitmap
|
||||
{
|
||||
public GeoBitmap(BitmapSource bitmapSource, Matrix transform, MapProjection projection)
|
||||
{
|
||||
BitmapSource = bitmapSource;
|
||||
|
||||
var p1 = transform.Transform(new Point());
|
||||
var p2 = transform.Transform(BitmapSize);
|
||||
|
||||
var p2 = transform.Transform(new Point(
|
||||
#if AVALONIA
|
||||
bitmapSource.PixelSize.Width, bitmapSource.PixelSize.Height));
|
||||
#else
|
||||
bitmapSource.PixelWidth, bitmapSource.PixelHeight));
|
||||
#endif
|
||||
BitmapSource = bitmapSource;
|
||||
LatLonBox = projection != null
|
||||
? new LatLonBox(projection.MapToBoundingBox(new Rect(p1, p2)))
|
||||
: new LatLonBox(p1.Y, p1.X, p2.Y, p2.X);
|
||||
|
|
@ -93,13 +96,21 @@ namespace MapControl
|
|||
|
||||
if (element is Image image)
|
||||
{
|
||||
image.Source = geoBitmap.BitmapSource;
|
||||
image.Stretch = Stretch.Fill;
|
||||
image.Source = geoBitmap.BitmapSource;
|
||||
}
|
||||
else if (element is Shape shape)
|
||||
{
|
||||
shape.Fill = geoBitmap.ImageBrush;
|
||||
shape.Stretch = Stretch.Fill;
|
||||
shape.Fill = new ImageBrush
|
||||
{
|
||||
Stretch = Stretch.Fill,
|
||||
#if AVALONIA
|
||||
Source = geoBitmap.BitmapSource
|
||||
#else
|
||||
ImageSource = geoBitmap.BitmapSource
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
MapPanel.SetBoundingBox(element, geoBitmap.LatLonBox);
|
||||
|
|
|
|||
|
|
@ -31,15 +31,15 @@ namespace MapControl
|
|||
{
|
||||
private class ImageOverlay
|
||||
{
|
||||
public ImageOverlay(BoundingBox boundingBox, string imagePath, int zIndex)
|
||||
public ImageOverlay(string imagePath, BoundingBox boundingBox, int zIndex)
|
||||
{
|
||||
BoundingBox = boundingBox;
|
||||
ImagePath = imagePath;
|
||||
BoundingBox = boundingBox;
|
||||
ZIndex = zIndex;
|
||||
}
|
||||
|
||||
public BoundingBox BoundingBox { get; }
|
||||
public string ImagePath { get; }
|
||||
public BoundingBox BoundingBox { get; }
|
||||
public int ZIndex { get; }
|
||||
public ImageSource ImageSource { get; set; }
|
||||
}
|
||||
|
|
@ -180,18 +180,18 @@ namespace MapControl
|
|||
{
|
||||
foreach (var groundOverlayElement in folderElement.Elements(ns + "GroundOverlay"))
|
||||
{
|
||||
var latLonBoxElement = groundOverlayElement.Element(ns + "LatLonBox");
|
||||
var latLonBox = latLonBoxElement != null ? ReadLatLonBox(latLonBoxElement) : null;
|
||||
|
||||
var imagePathElement = groundOverlayElement.Element(ns + "Icon");
|
||||
var imagePath = imagePathElement?.Element(ns + "href")?.Value;
|
||||
|
||||
var latLonBoxElement = groundOverlayElement.Element(ns + "LatLonBox");
|
||||
var latLonBox = latLonBoxElement != null ? ReadLatLonBox(latLonBoxElement) : null;
|
||||
|
||||
var drawOrder = groundOverlayElement.Element(ns + "drawOrder")?.Value;
|
||||
var zIndex = drawOrder != null ? int.Parse(drawOrder) : 0;
|
||||
|
||||
if (latLonBox != null && imagePath != null)
|
||||
{
|
||||
yield return new ImageOverlay(latLonBox, imagePath, zIndex);
|
||||
yield return new ImageOverlay(imagePath, latLonBox, zIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue