Skip to content

Commit

Permalink
Merge pull request #1 from chucker/fixes/41-nullable-anchor-and-size
Browse files Browse the repository at this point in the history
Likely workaround Mehigh17#41 icon size/anchor in WASM
  • Loading branch information
Yeetii authored Nov 16, 2022
2 parents 150b6ca + f16473d commit 17c5bc7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 14 additions & 4 deletions BlazorLeaflet/BlazorLeaflet/Models/Icon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,25 @@ public class Icon
/// </summary>
public string RetinalUrl { get; set; }

public bool HasSize { get; set; }

/// <summary>
/// Size of the icon image in pixels.
/// <para>Size of the icon image in pixels.</para>
///
/// <para>To use, set <see cref="HasSize"/> to <see cref="true"/>.</para>
/// </summary>
public Size? Size { get; set; }
public Size Size { get; set; }

public bool HasAnchor { get; set; }

/// <summary>
/// The coordinates of the "tip" of the icon (relative to its top left corner). The icon will be aligned so that this point is at the marker's geographical location. Centered by default if size is specified, also can be set in CSS with negative margins.
/// <para>The coordinates of the "tip" of the icon (relative to its top left corner). The icon will be aligned
/// so that this point is at the marker's geographical location. Centered by default if size is specified, also
/// can be set in CSS with negative margins.</para>
///
/// <para>To use, set <see cref="HasAnchor"/> to <see cref="true"/>.</para>
/// </summary>
public Point? Anchor { get; set; }
public Point Anchor { get; set; }

/// <summary>
/// The coordinates of the point from which popups will "open", relative to the icon anchor.
Expand Down
4 changes: 2 additions & 2 deletions BlazorLeaflet/BlazorLeaflet/wwwroot/leafletBlazorInterops.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ function createIcon(icon) {
return L.icon({
iconUrl: icon.url,
iconRetinaUrl: icon.retinaUrl,
iconSize: icon.size ? L.point(icon.size.value.width, icon.size.value.height) : null,
iconAnchor: icon.anchor ? L.point(icon.anchor.value.x, icon.anchor.value.y) : null,
iconSize: icon.hasSize ? L.point(icon.size.width, icon.size.height) : null,
iconAnchor: icon.hasAnchor ? L.point(icon.anchor.x, icon.anchor.y) : null,
popupAnchor: L.point(icon.popupAnchor.x, icon.popupAnchor.y),
tooltipAnchor: L.point(icon.tooltipAnchor.x, icon.tooltipAnchor.y),
shadowUrl: icon.shadowUrl,
Expand Down

0 comments on commit 17c5bc7

Please sign in to comment.