Skip to content

Commit

Permalink
Incorrect Method Names and Calls for Polygon and Rectangle Drag Funct…
Browse files Browse the repository at this point in the history
…ionality #288 release and minor cleanup
  • Loading branch information
valentasm committed Nov 23, 2023
1 parent 278d3bd commit 09e47d2
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 175 deletions.
2 changes: 1 addition & 1 deletion GoogleMapsComponents/GoogleMapsComponents.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<RazorLangVersion>3.0</RazorLangVersion>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<PackageId>BlazorGoogleMaps</PackageId>
<Version>3.2.3</Version>
<Version>3.2.4</Version>
<Authors>Rungwiroon</Authors>
<Company>QueueStack Solution</Company>
<Product>BlazorGoogleMaps</Product>
Expand Down
23 changes: 12 additions & 11 deletions GoogleMapsComponents/Maps/Extension/ListableEntityListBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ListableEntityListBase<TEntityBase, TEntityOptionsBase> : IDisposab
protected readonly JsObjectRef _jsObjectRef;

public readonly Dictionary<string, TEntityBase> BaseListableEntities;
private bool isDisposed;
private bool _isDisposed;

protected ListableEntityListBase(JsObjectRef jsObjectRef, Dictionary<string, TEntityBase> baseListableEntities)
{
Expand Down Expand Up @@ -217,10 +217,10 @@ protected virtual Dictionary<Guid, object> ComputeDictArgs(List<string> matching
//Create an empty result of the correct type in case of no matching keys
protected virtual Task<Dictionary<string, T>> ComputeEmptyResult<T>()
{
return Task<Dictionary<string, T>>.Factory.StartNew(() => { return new Dictionary<string, T>(); });
return Task<Dictionary<string, T>>.Factory.StartNew(() => new Dictionary<string, T>());
}

public virtual Task<Dictionary<string, Map>> GetMaps(List<string> filterKeys = null)
public virtual Task<Dictionary<string, Map>> GetMaps(List<string>? filterKeys = null)
{
List<string> matchingKeys = ComputeMathingKeys(filterKeys);

Expand All @@ -240,7 +240,7 @@ public virtual Task<Dictionary<string, Map>> GetMaps(List<string> filterKeys = n
}
}

public virtual Task<Dictionary<string, bool>> GetDraggables(List<string> filterKeys = null)
public virtual Task<Dictionary<string, bool>> GetDraggables(List<string>? filterKeys = null)
{
List<string> matchingKeys = ComputeMathingKeys(filterKeys);

Expand All @@ -260,7 +260,7 @@ public virtual Task<Dictionary<string, bool>> GetDraggables(List<string> filterK
}
}

public virtual Task<Dictionary<string, bool>> GetVisibles(List<string> filterKeys = null)
public virtual Task<Dictionary<string, bool>> GetVisibles(List<string>? filterKeys = null)
{
List<string> matchingKeys = ComputeMathingKeys(filterKeys);

Expand All @@ -284,9 +284,10 @@ public virtual Task<Dictionary<string, bool>> GetVisibles(List<string> filterKey
/// Renders the listable entity on the specified map or panorama.
/// If map is set to null, the marker will be removed.
/// </summary>
/// <param name="map"></param>
public virtual async Task SetMaps(Dictionary<string, Map> maps)
/// <param name="maps"></param>
public virtual async Task SetMaps(Dictionary<string, Map>? maps)
{
maps ??= new Dictionary<string, Map>();
Dictionary<Guid, object> dictArgs = maps.ToDictionary(e => BaseListableEntities[e.Key].Guid, e => (object)e.Value);
await _jsObjectRef.InvokeMultipleAsync(
"setMap",
Expand Down Expand Up @@ -342,15 +343,15 @@ protected virtual async ValueTask DisposeAsyncCore()
{
if (BaseListableEntities.Count > 0)
{
await _jsObjectRef.DisposeMultipleAsync(BaseListableEntities.Select(e => e.Value.Guid).ToList());
await _jsObjectRef.DisposeMultipleAsync(BaseListableEntities.Select(e => e.Value.Guid).ToList());
BaseListableEntities.Clear();
}
}

protected virtual void Dispose(bool disposing)
{
if (!isDisposed)

if (!_isDisposed)
{
if (disposing)
{
Expand All @@ -359,7 +360,7 @@ protected virtual void Dispose(bool disposing)

// TODO: free unmanaged resources (unmanaged objects) and override finalizer
// TODO: set large fields to null
isDisposed = true;
_isDisposed = true;
}
}

Expand Down
102 changes: 35 additions & 67 deletions GoogleMapsComponents/Maps/Extension/MarkerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ public class MarkerList : ListableEntityListBase<Marker, MarkerOptions>
/// <returns>new instance of MarkerList class will be returned with its Markers dictionary member populated with the corresponding results</returns>
public static async Task<MarkerList> CreateAsync(IJSRuntime jsRuntime, Dictionary<string, MarkerOptions> opts)
{
JsObjectRef jsObjectRef = new JsObjectRef(jsRuntime, Guid.NewGuid());
var jsObjectRef = new JsObjectRef(jsRuntime, Guid.NewGuid());

MarkerList obj;
Dictionary<string, JsObjectRef> jsObjectRefs = await JsObjectRef.CreateMultipleAsync(
jsRuntime,
"google.maps.Marker",
opts.ToDictionary(e => e.Key, e => (object)e.Value));

Dictionary<string, Marker> objs = jsObjectRefs.ToDictionary(e => e.Key, e => new Marker(e.Value));
obj = new MarkerList(jsObjectRef, objs);
var obj = new MarkerList(jsObjectRef, objs);

return obj;
}
Expand Down Expand Up @@ -74,7 +73,7 @@ public static async Task<MarkerList> SyncAsync(MarkerList? list,
list = await MarkerList.CreateAsync(jsRuntime, new Dictionary<string, MarkerOptions>());
if (clickCallback != null)
{
list.EntityClicked += (sender, e) =>
list.EntityClicked += (_, e) =>
{
clickCallback(e.MouseEvent, e.Key, e.Entity);
};
Expand Down Expand Up @@ -112,7 +111,7 @@ public async Task AddMultipleAsync(Dictionary<string, MarkerOptions> opts)

public Task<Dictionary<string, Animation>> GetAnimations(List<string>? filterKeys = null)
{
List<string> matchingKeys = ComputeMathingKeys(filterKeys);
var matchingKeys = ComputeMathingKeys(filterKeys);

if (matchingKeys.Any())
{
Expand All @@ -131,7 +130,7 @@ public Task<Dictionary<string, Animation>> GetAnimations(List<string>? filterKey

public Task<Dictionary<string, bool>> GetClickables(List<string>? filterKeys = null)
{
List<string> matchingKeys = ComputeMathingKeys(filterKeys);
var matchingKeys = ComputeMathingKeys(filterKeys);

if (matchingKeys.Any())
{
Expand All @@ -150,7 +149,7 @@ public Task<Dictionary<string, bool>> GetClickables(List<string>? filterKeys = n

public Task<Dictionary<string, string>> GetCursors(List<string>? filterKeys = null)
{
List<string> matchingKeys = ComputeMathingKeys(filterKeys);
var matchingKeys = ComputeMathingKeys(filterKeys);

if (matchingKeys.Any())
{
Expand All @@ -169,7 +168,7 @@ public Task<Dictionary<string, string>> GetCursors(List<string>? filterKeys = nu

public Task<Dictionary<string, OneOf<string, Icon, Symbol>>> GetIcons(List<string>? filterKeys = null)
{
List<string> matchingKeys = ComputeMathingKeys(filterKeys);
var matchingKeys = ComputeMathingKeys(filterKeys);

if (matchingKeys.Any())
{
Expand All @@ -188,7 +187,7 @@ public Task<Dictionary<string, OneOf<string, Icon, Symbol>>> GetIcons(List<strin

public Task<Dictionary<string, string>> GetLabels(List<string>? filterKeys = null)
{
List<string> matchingKeys = ComputeMathingKeys(filterKeys);
var matchingKeys = ComputeMathingKeys(filterKeys);

if (matchingKeys.Any())
{
Expand All @@ -207,7 +206,7 @@ public Task<Dictionary<string, string>> GetLabels(List<string>? filterKeys = nul

public Task<Dictionary<string, LatLngLiteral>> GetPositions(List<string>? filterKeys = null)
{
List<string> matchingKeys = ComputeMathingKeys(filterKeys);
var matchingKeys = ComputeMathingKeys(filterKeys);

if (matchingKeys.Any())
{
Expand All @@ -226,7 +225,7 @@ public Task<Dictionary<string, LatLngLiteral>> GetPositions(List<string>? filter

public Task<Dictionary<string, MarkerShape>> GetShapes(List<string>? filterKeys = null)
{
List<string> matchingKeys = ComputeMathingKeys(filterKeys);
var matchingKeys = ComputeMathingKeys(filterKeys);

if (matchingKeys.Any())
{
Expand All @@ -245,7 +244,7 @@ public Task<Dictionary<string, MarkerShape>> GetShapes(List<string>? filterKeys

public Task<Dictionary<string, string>> GetTitles(List<string>? filterKeys = null)
{
List<string> matchingKeys = ComputeMathingKeys(filterKeys);
var matchingKeys = ComputeMathingKeys(filterKeys);

if (matchingKeys.Any())
{
Expand All @@ -264,7 +263,7 @@ public Task<Dictionary<string, string>> GetTitles(List<string>? filterKeys = nul

public Task<Dictionary<string, int>> GetZIndexes(List<string>? filterKeys = null)
{
List<string> matchingKeys = ComputeMathingKeys(filterKeys);
var matchingKeys = ComputeMathingKeys(filterKeys);

if (matchingKeys.Any())
{
Expand All @@ -290,10 +289,8 @@ public Task<Dictionary<string, int>> GetZIndexes(List<string>? filterKeys = null
/// <param name="animations"></param>
public Task SetAnimations(Dictionary<string, Animation?> animations)
{
Dictionary<Guid, object?> dictArgs = animations.ToDictionary(e => Markers[e.Key].Guid, e => (object?)GetAnimationCode(e.Value));
return _jsObjectRef.InvokeMultipleAsync(
"setAnimation",
dictArgs);
var dictArgs = animations.ToDictionary(e => Markers[e.Key].Guid, e => (object?)GetAnimationCode(e.Value));
return _jsObjectRef.InvokeMultipleAsync("setAnimation", dictArgs);
}

public int? GetAnimationCode(Animation? animation)
Expand All @@ -314,18 +311,14 @@ public Task SetAnimations(Dictionary<string, Animation?> animations)
/// <returns></returns>
public Task SetClickables(Dictionary<string, bool> flags)
{
Dictionary<Guid, object> dictArgs = flags.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setClickable",
dictArgs);
var dictArgs = flags.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync("setClickable", dictArgs);
}

public Task SetCursors(Dictionary<string, string> cursors)
{
Dictionary<Guid, object> dictArgs = cursors.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setCursor",
dictArgs);
var dictArgs = cursors.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync("setCursor", dictArgs);
}

/// <summary>
Expand All @@ -335,7 +328,7 @@ public Task SetCursors(Dictionary<string, string> cursors)
/// <returns></returns>
public Task SetIcons(Dictionary<string, OneOf<string, Icon, Symbol>> icons)
{
Dictionary<Guid, object> dictArgs = icons.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
var dictArgs = icons.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setIcon",
dictArgs);
Expand All @@ -344,40 +337,25 @@ public Task SetIcons(Dictionary<string, OneOf<string, Icon, Symbol>> icons)
/// <inheritdoc cref="SetIcons(Dictionary{string, OneOf{string, Icon, Symbol}})"/>
public Task SetIcons(Dictionary<string, string> icons)
{
Dictionary<Guid, object> dictArgs = icons.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setIcon",
dictArgs);
var dictArgs = icons.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync("setIcon", dictArgs);
}

/// <inheritdoc cref="SetIcons(Dictionary{string, OneOf{string, Icon, Symbol}})"/>
public Task SetIcons(Dictionary<string, Icon> icons)
{
Dictionary<Guid, object> dictArgs = icons.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setIcon",
dictArgs);
var dictArgs = icons.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync("setIcon", dictArgs);
}


// <inheritdoc cref="SetLabels(Dictionary{string, OneOf{string, MarkerLabel}})"/>
//[Obsolete("Use overloads that take string, MarkerLabel, or OneOf<string, MarkerLabel> as dictionary value type.")]
//public Task SetLabels(Dictionary<string, Symbol> labels)
//{
// Dictionary<Guid, object> dictArgs = labels.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
// return _jsObjectRef.InvokeMultipleAsync(
// "setLabel",
// dictArgs);
//}

/// <summary>
/// Set Label on each Marker matching a param dictionary key to the param value with single JSInterop call.
/// </summary>
/// <param name="labels"></param>
/// <returns></returns>
public Task SetLabels(Dictionary<string, OneOf<string, MarkerLabel>> labels)
{
Dictionary<Guid, object> dictArgs = labels.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
var dictArgs = labels.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setLabel",
dictArgs);
Expand All @@ -386,7 +364,7 @@ public Task SetLabels(Dictionary<string, OneOf<string, MarkerLabel>> labels)
/// <inheritdoc cref="SetLabels(Dictionary{string, OneOf{string, MarkerLabel}})"/>
public Task SetLabels(Dictionary<string, string> labels)
{
Dictionary<Guid, object> dictArgs = labels.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
var dictArgs = labels.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setLabel",
dictArgs);
Expand All @@ -395,51 +373,41 @@ public Task SetLabels(Dictionary<string, string> labels)
/// <inheritdoc cref="SetLabels(Dictionary{string, OneOf{string, MarkerLabel}})"/>
public Task SetLabels(Dictionary<string, MarkerLabel> labels)
{
Dictionary<Guid, object> dictArgs = labels.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
var dictArgs = labels.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setLabel",
dictArgs);
}



public Task SetOpacities(Dictionary<string, float> opacities)
{
Dictionary<Guid, object> dictArgs = opacities.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
var dictArgs = opacities.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setOpacity",
dictArgs);
}

public Task SetPositions(Dictionary<string, LatLngLiteral> latLngs)
{
Dictionary<Guid, object> dictArgs = latLngs.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setPosition",
dictArgs);
var dictArgs = latLngs.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync("setPosition", dictArgs);
}

public Task SetShapes(Dictionary<string, MarkerShape> shapes)
{
Dictionary<Guid, object> dictArgs = shapes.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setShape",
dictArgs);
var dictArgs = shapes.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync("setShape", dictArgs);
}

public Task SetTitles(Dictionary<string, string> titles)
{
Dictionary<Guid, object> dictArgs = titles.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setTitle",
dictArgs);
var dictArgs = titles.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync("setTitle", dictArgs);
}

public Task SetZIndexes(Dictionary<string, int> zIndexes)
{
Dictionary<Guid, object> dictArgs = zIndexes.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync(
"setZIndex",
dictArgs);
var dictArgs = zIndexes.ToDictionary(e => Markers[e.Key].Guid, e => (object)e.Value);
return _jsObjectRef.InvokeMultipleAsync("setZIndex", dictArgs);
}
}
25 changes: 1 addition & 24 deletions GoogleMapsComponents/Maps/Icon.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace GoogleMapsComponents.Maps;
namespace GoogleMapsComponents.Maps;

/// <summary>
/// A structure representing a Marker icon image.
Expand Down Expand Up @@ -43,25 +41,4 @@ public class Icon
/// The URL of the image or sprite sheet.
/// </summary>
public string Url { get; set; }

[Obsolete("Not used. Will remove in future releases")]
public string FillColor { get; set; }

[Obsolete("Not used. Will remove in future releases")]
public int Rotation { get; set; }

[Obsolete("Not used. Will remove in future releases")]
public string Path { get; set; }

[Obsolete("Not used. Will remove in future releases")]
public double FillOpacity { get; set; }

[Obsolete("Not used. Will remove in future releases")]
public int StrokeWeight { get; set; }

[Obsolete("Not used. Will remove in future releases")]
public string StrokeColor { get; set; }

[Obsolete("Not used. Will remove in future releases")]
public double Scale { get; set; }
}
Loading

0 comments on commit 09e47d2

Please sign in to comment.