-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Feature/64 add kmllayer #199
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and clean, great start!
|
||
namespace dymaptic.GeoBlazor.Core.Components.Layers; | ||
|
||
public class KMLLayer : Layer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need XML comments on all public types and properties for the docs site.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments are now in place after the class was refactored
kmlLayer = new KMLLayer({ portalItem: portalItem }); | ||
} | ||
newLayer = kmlLayer; | ||
copyValuesIfExists(layerObject, kmlLayer, 'sublayers', 'blendMode', 'maxScale', 'minScale', 'title', 'visible'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyValuesIfExists
is shorthand for everything you have below it, so you can delete lines 2038-2049. The only reason to not use copyValuesIfExists
is if you need to transform the value somehow, such as using a buildJS
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed and understand, there are no transformations at this time, but enabling editing may require this in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can evaluate each property individually, if there is something that needs to be spelled out, just leave it out of the copyValues
list and implement it fully.
|
||
[Parameter] | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string? Url { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the [RequiredProperty]
attribute to Url
and PortalItem
(each one should reference the other one). see FeatureLayer
for the example. This should throw an error if a user forgets to set either a Url or a PortalItem with Id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored the constructor, included error and added Required Property to Url.
public async Task AddKMLLayer() | ||
{ | ||
_visible = true; | ||
await LoadKMlLayer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're defining the KML layer twice, once in markup on line 17, and separately in C# on line 37. So you have added the same layer twice. I know @AndersenBell was suggesting that we try to show off the different ways of adding things, but I think this can be confusing and imply that you have to do both, and it would be more clear if they were separate layers, possibly triggered by separate buttons, like Add Layer in Markup
and Add Layer in Code
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Just a bit more to implement.
kmlLayer = new KMLLayer({ portalItem: portalItem }); | ||
} | ||
newLayer = kmlLayer; | ||
copyValuesIfExists(layerObject, kmlLayer, 'sublayers', 'blendMode', 'maxScale', 'minScale', 'title', 'visible'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can evaluate each property individually, if there is something that needs to be spelled out, just leave it out of the copyValues
list and implement it fully.
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[RequiredProperty(nameof(PortalItem))] | ||
public string? Url { get; set; } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so your code here and in the TypeScript says you are supporting PortalItem
, but you haven't implemented it.
You need
- A new
public PortalItem? PortalItem { get; set; }
. NOT a[Parameter]
- Implement
protected override async Task RegisterChildComponent(MapComponent child)
- Implement
protected override async Task UnRegisterChildComponent
- Implement
internal void ValidateRequiredChildred()
.
This is how nested markup components get registered to work. You could create a test in Core.Test.Blazor
or a separate sample that lays out a KML like this
<KmlLayer>
<PortalItem Id="..." />
</KmlLayer>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored the main class and adjusted the markup component to use the url parameter. Also created a layer test class for the kml layer and successfully tested. Thanks for the assist @TimPurdum Additional layers can also be added in the future to this test file.
….razor, successful test result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hook up the new samples page to the nav menu. Nice work on this!
@@ -0,0 +1,53 @@ | |||
@page "/kmllayers" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this page added to navMenu.razor
? I don't see it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected that oversight
|
||
<div class="links-div"> | ||
<a class="btn btn-secondary" target="_blank" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-KMLLayer.html">ArcGIS API for JavaScript</a> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a second link for the KML Layer source (see other sample pages for example).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source url is now included and reformatted the page to display better.
<Map ArcGISDefaultBasemap="dark-gray-vector"> | ||
@if (_markup) | ||
{ | ||
<KMLLayer Url="https://earthquake.usgs.gov/fdsnws/event/1/query?format=kml&minmagnitude=5.8" Title="Major EarthQuakes Query Result"></KMLLayer> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have this url string as a field already, you could just set it here with <KMLLayer Url="@_kmlLayerUrl" Title="Major Earthquakes Query Result" />
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected
CreateViewRenderedHandler(async () => | ||
{ | ||
await AssertJavaScript("assertKmlLayerExists"); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent formatting is a bit wonky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was a copy paste oversight when bringing this file in after the new test folder was created. good to go
if (layers !== 'kml') { | ||
throw new Error(`There are no Layers in this view`); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually simpler than the code I used to find the widgets, so nice work!
Closes #64
Adds KML Layers to the layer types that can be added/used in geoblazor.
sample page could be consolidated in the future with other layer types.