Skip to content

Commit

Permalink
Merge pull request #244 from dymaptic/feature/feature-enhancements-pr…
Browse files Browse the repository at this point in the history
…o-58

Widget and Feature Enhancements
  • Loading branch information
TimPurdum authored Oct 24, 2023
2 parents 98abc69 + 43c6f38 commit 4d80196
Show file tree
Hide file tree
Showing 46 changed files with 1,831 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

private void OnLayerViewCreate(LayerViewCreateEvent evt)
{
if (evt.Layer is not FeatureLayer layer) return;
if (evt.Layer is not FeatureLayer) return;
_layerView = evt.LayerView as FeatureLayerView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<p class="instructions">
This sample shows a CSV layer of earthquake data. You can add a new CSV layer by entering a CSV url in the input below.
</p>
<Label>Enter CSV Layer URL:</Label>
<label>Enter CSV Layer URL:</label>
<InputText @bind-Value="_csvLayerUrl"></InputText>
<button disabled="@(!_viewRendered)" @onclick="AddLayer">Add new CSV Layer!</button>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,4 @@
SingleLineFieldName="SingleLine"
Url="https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer" />
</SearchWidget>
</MapView>

@code {
private readonly FeatureLayer _districtsLayer = new(
"",
popupTemplate: new PopupTemplate("",
overwriteActions: true));

private readonly FeatureLayer _senatorsLayer = new(
"https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators_2020/FeatureServer/0",
popupTemplate: new PopupTemplate("<a href={Web_Page} target='_blank'> {Name}</a>, ({Party}-{State}) ",
overwriteActions: true));
}
</MapView>
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
<GraphicsLayer @ref="_refreshableGraphicsLayer">
@for (var i = 0; i < _graphicsCount; i++)
{
var index = i;
<Graphic>
<Point Longitude="_longs[i]" Latitude="_lats[i]" />
<Point Longitude="_longs[index]" Latitude="_lats[index]" />
</Graphic>
}
</GraphicsLayer>
Expand Down
119 changes: 119 additions & 0 deletions src/dymaptic.GeoBlazor.Core/Components/Layers/ColorVariable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
using dymaptic.GeoBlazor.Core.Objects;
using Microsoft.AspNetCore.Components;
using System.Text.Json.Serialization;


namespace dymaptic.GeoBlazor.Core.Components.Layers;

/// <summary>
/// The color visual variable is used to visualize features along a continuous color ramp based on the values of a numeric attribute field or an expression. The color ramp is defined along a sequence of stops, where color values are mapped to data values. Data values that fall between two stops are assigned a color that is linearly interpolated based on the value's position relative to the closest defined stops.
/// <a target="_blank" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-visualVariables-ColorVariable.html">ArcGIS Maps SDK for JavaScript</a>
/// </summary>
public class ColorVariable : VisualVariable
{
/// <inheritdoc />
public override VisualVariableType VariableType => VisualVariableType.Color;

/// <summary>
/// Name of the numeric attribute field by which to normalize the data. If this field is used, then the values in stops should be normalized as percentages or ratios.
/// </summary>
[Parameter]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? NormalizationField { get; set; }

/// <summary>
/// An array of sequential objects, or stops, that defines a continuous color ramp. You must specify 2 - 8 stops. In most cases, no more than five are needed. Features with values that fall between the given stops will be assigned colors linearly interpolated along the ramp in relation to the nearest stop values. The stops must be listed in ascending order based on the value of the value property in each stop.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IReadOnlyCollection<ColorStop>? Stops
{
get => _stops;
set
{
if (value is not null)
{
_stops = new HashSet<ColorStop>(value);
}
else
{
_stops = null;
}
}
}

/// <inheritdoc />
public override async Task RegisterChildComponent(MapComponent child)
{
switch (child)
{
case ColorStop stop:
_stops ??= new HashSet<ColorStop>();
_stops.Add(stop);

break;
default:
await base.RegisterChildComponent(child);

break;
}
}

/// <inheritdoc />
public override async Task UnregisterChildComponent(MapComponent child)
{
switch (child)
{
case ColorStop stop:
_stops?.Remove(stop);

break;
default:
await base.UnregisterChildComponent(child);

break;
}
}

internal override void ValidateRequiredChildren()
{
base.ValidateRequiredChildren();

if (_stops is not null)
{
foreach (ColorStop stop in _stops)
{
stop.ValidateRequiredChildren();
}
}
}

private HashSet<ColorStop>? _stops;
}

/// <summary>
/// Defines a color stop used for creating a continuous color visualization in a color visual variable.
/// <a target="_blank" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-visualVariables-support-ColorStop.html">ArcGIS Maps SDK for JavaScript</a>
/// </summary>
public class ColorStop: MapComponent
{
/// <summary>
/// The Color used to render features with the given value.
/// </summary>
[Parameter]
[RequiredProperty]
public MapColor? Color { get; set; }

/// <summary>
/// A string value used to label the stop along the color ramp in the Legend.
/// </summary>
[Parameter]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Label { get; set; }

/// <summary>
/// Specifies the data value to map to the given color.
/// </summary>
[Parameter]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? Value { get; set; }
}
37 changes: 36 additions & 1 deletion src/dymaptic.GeoBlazor.Core/Components/Layers/FeatureLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ public FeatureLayer(string? url = null, PortalItem? portalItem = null, IReadOnly
PopupTemplate = popupTemplate;
#pragma warning restore BL0005 // Component parameter should not be set outside of its component.
}

/// <summary>
/// An authorization string used to access a resource or service. API keys are generated and managed in the ArcGIS Developer dashboard. An API key is tied explicitly to an ArcGIS account; it is also used to monitor service usage. Setting a fine-grained API key on a specific class overrides the global API key.
/// </summary>
[Parameter]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ApiKey { get; set; }

/// <summary>
/// Blend modes are used to blend layers together to create an interesting effect in a layer, or even to produce what seems like a new layer. Unlike the method of using transparency which can result in a washed-out top layer, blend modes can create a variety of very vibrant and intriguing results by blending a layer with the layer(s) below it.
/// </summary>
[Parameter]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public BlendMode? BlendMode { get; set; }

/// <summary>
/// The absolute URL of the REST endpoint of the layer, non-spatial table or service
Expand Down Expand Up @@ -156,6 +170,20 @@ public FeatureLayer(string? url = null, PortalItem? portalItem = null, IReadOnly
[Parameter]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public GeometryType? GeometryType { get; set; }

/// <summary>
/// Indicates whether the layer will be included in the legend.
/// </summary>
[Parameter]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? LegendEnabled { get; set; }

/// <summary>
/// Indicates whether to display popups when features in the layer are clicked.
/// </summary>
[Parameter]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? PopupEnabled { get; set; }

/// <summary>
/// Determines the order in which features are drawn in the view.
Expand Down Expand Up @@ -352,10 +380,17 @@ public async Task<FeatureEditsResult> ApplyEdits(FeatureEdits edits, FeatureEdit
return await JsLayerReference!.InvokeAsync<Domain?>("getFieldDomain", fieldName, feature);
}

/// <summary>
/// Describes the layer's supported capabilities.
/// </summary>
public async Task<FeatureLayerCapabilities> GetCapabilities()
{
return await JsLayerReference!.InvokeAsync<FeatureLayerCapabilities>("getCapabilities");
}

/// <summary>
/// Creates a deep clone of the javascript FeatureLayer object.
/// </summary>
/// <returns></returns>
public async Task<FeatureLayer> Clone()
{
return await JsLayerReference!.InvokeAsync<FeatureLayer>("clone");
Expand Down
Loading

0 comments on commit 4d80196

Please sign in to comment.