Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Likely workaround #41 icon size/anchor in WASM #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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