Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"permissions": {
"allow": [
"Bash(gh api:*)",
"WebFetch(domain:aka.ms)"
"WebFetch(domain:aka.ms)",
"WebFetch(domain:raw.githubusercontent.com)"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@page "/basemap-toggle-widget"
@inherits SamplePage

<PageTitle>Basemap Toggle Widget</PageTitle>
<h1>Basemap Toggle Widget</h1>

<p class="instructions">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my changes moving links-div links to PageLinks in the @code block. I would like you to update the other 4 samples in the same way.

The Basemap Toggle widget allows switching between two basemap styles with a single click.
Select a basemap pair below, then click the toggle button in the bottom-right corner of the map
to switch between the two styles.
</p>

<div class="form-group">
<div class="spaced-row">
<label for="pair-select">Basemap Pair:</label>
<select id="pair-select" @bind="_pairIndex">
<option value="0">Satellite / Colored Pencil</option>
<option value="1">Topographic / Dark Gray</option>
<option value="2">Navigation / Imagery</option>
<option value="3">OSM Standard / Terrain</option>
</select>
</div>
</div>

@* @key forces the MapView to remount when the basemap pair changes. The primary
<BasemapStyle Name="..."> swap inside <Map> is not propagated reactively today,
so a remount is the simplest way to demonstrate different pairs. *@
<MapView Longitude="-118.24" Latitude="34.05" Zoom="12" Class="map-view">
<Map>
<Basemap>
<BasemapStyle Name="@_pairs[_pairIndex].Primary" />
</Basemap>
</Map>
<BasemapToggleWidget NextBasemapStyle="@_pairs[_pairIndex].Secondary"
Position="OverlayPosition.BottomRight" />
</MapView>

@code {
public override List<NavMenu.PageLink> PageLinks =>
[
new("https://developers.arcgis.com/javascript/latest/sample-code/widgets-basemaptoggle/", "ArcGIS Maps SDK for JavaScript"),
new("https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html", "Basemap Toggle API Reference")
];

private int _pairIndex;

private readonly (BasemapStyleName Primary, BasemapStyleName Secondary)[] _pairs =
[
(BasemapStyleName.ArcgisImageryStandard, BasemapStyleName.ArcgisColoredPencil),
(BasemapStyleName.ArcgisTopographic, BasemapStyleName.ArcgisDarkGray),
(BasemapStyleName.ArcgisNavigation, BasemapStyleName.ArcgisImagery),
(BasemapStyleName.OsmStandard, BasemapStyleName.ArcgisTerrain),
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@page "/compass-widget"
@inherits SamplePage

<PageTitle>Compass Widget</PageTitle>
<h1>Compass Widget</h1>

<p class="instructions">
The Compass widget indicates the map's current orientation relative to north.
Use the buttons below to rotate the map, then click the compass to reset to north.
The compass only appears when the map is rotated away from north.
</p>

<div class="form-group spaced-row">
<label>Rotate Map:</label>
<button class="btn btn-secondary btn-small" @onclick="@(() => SetRotation(45))">45&deg;</button>
<button class="btn btn-secondary btn-small" @onclick="@(() => SetRotation(90))">90&deg;</button>
<button class="btn btn-secondary btn-small" @onclick="@(() => SetRotation(180))">180&deg;</button>
<button class="btn btn-secondary btn-small" @onclick="@(() => SetRotation(270))">270&deg;</button>
<button class="btn btn-accent btn-small" @onclick="@(() => SetRotation(0))">Reset North</button>
<span>Current: @(_rotation)&deg;</span>
</div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see notes on ScaleBar page about styling

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, you can combine form-group and spaced-row to get a similar effect. It's fine to use the style block if you have to override the final result of those classes, but try those first.


<MapView @ref="_mapView" Longitude="-118.805" Latitude="34.027" Zoom="13" Rotation="@_rotation"
OnExtentChanged="OnViewExtentChanged" Class="map-view">
<Map>
<Basemap>
<BasemapStyle Name="BasemapStyleName.ArcgisTopographic" />
</Basemap>
</Map>
<CompassWidget Position="OverlayPosition.TopLeft" />
</MapView>

@code {
public override List<NavMenu.PageLink> PageLinks =>
[
new("https://developers.arcgis.com/javascript/latest/sample-code/widgets-compass/", "ArcGIS Maps SDK for JavaScript"),
new("https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass.html", "Compass API Reference")
];

private MapView? _mapView;
private double _rotation;

private async Task SetRotation(double degrees)
{
_rotation = degrees;
if (_mapView is not null)
{
await _mapView.SetRotation(degrees);
}
}

private async Task OnViewExtentChanged(Extent _)
{
if (_mapView is not null)
{
double? current = await _mapView.GetRotation();
_rotation = current ?? 0;
StateHasChanged();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@

@if (_showCensusLayer)
{
<FeatureLayer @ref="_censusLayer"
Title="Census Block Points"
<FeatureLayer Title="Census Block Points"
Url="https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/ACS_Population_by_Race_and_Hispanic_Origin_Boundaries/FeatureServer/2"
Opacity="0.6">
<SimpleRenderer>
Expand Down Expand Up @@ -106,12 +105,11 @@

public override List<NavMenu.PageLink> PageLinks =>
[
new("https://developers.arcgis.com/javascript/latest/sample-code/legend/", "ArcGIS Sample"),
new("https://developers.arcgis.com/javascript/latest/sample-code/legend/", "ArcGIS Maps SDK for JavaScript"),
new("https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html", "Legend API Reference")
];

private bool _showCensusLayer;
private bool _showTrailsLayer;
private bool _showParksLayer;
private FeatureLayer? _censusLayer;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@page "/locate-widget"
@inherits SamplePage

<PageTitle>Locate Widget</PageTitle>
<h1>Locate Widget</h1>

<p class="instructions">
The Locate widget uses the browser's Geolocation API to find and navigate to your current position.
Click the <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="inline-icon" aria-hidden="true" focusable="false">
<circle cx="8" cy="8" r="6" stroke="currentColor" stroke-width="1.5" fill="none"/>
<circle cx="8" cy="8" r="1.5" fill="currentColor"/>
<line x1="8" y1="0" x2="8" y2="3" stroke="currentColor" stroke-width="1.5"/>
<line x1="8" y1="13" x2="8" y2="16" stroke="currentColor" stroke-width="1.5"/>
<line x1="0" y1="8" x2="3" y2="8" stroke="currentColor" stroke-width="1.5"/>
<line x1="13" y1="8" x2="16" y2="8" stroke="currentColor" stroke-width="1.5"/>
</svg> button (top-left of the map) to fly to your location. Most browsers will show an
"Allow" permissions dialog the first time &mdash; accept it to share your location with the page.
Change the scale below, then click the button again to see the difference.
</p>

<div class="form-group">
<div class="spaced-row">
<label for="scale-select">Scale:</label>
<select id="scale-select" @bind="_scale">
<option value="1500">1,500 (Street level)</option>
<option value="5000">5,000 (Neighborhood)</option>
<option value="25000">25,000 (City)</option>
<option value="100000">100,000 (Region)</option>
</select>
</div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see ScaleBar page style notes

</div>

<MapView Longitude="-98.5" Latitude="39.8" Zoom="4" Class="map-view">
<Map>
<Basemap>
<BasemapStyle Name="BasemapStyleName.ArcgisNavigation" />
</Basemap>
</Map>
<LocateWidget Position="OverlayPosition.TopLeft"
Scale="@_scale"
PopupEnabled="true" />
</MapView>

@code {
public override List<NavMenu.PageLink> PageLinks =>
[
new("https://developers.arcgis.com/javascript/latest/sample-code/widgets-locate/", "ArcGIS Sample"),
new("https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html", "Locate API Reference")
];

private int _scale = 1500;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.inline-icon {
vertical-align: middle;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@page "/scale-bar-widget"
@inherits SamplePage

<PageTitle>Scale Bar Widget</PageTitle>
<h1>Scale Bar Widget</h1>

<p class="instructions">
The Scale Bar widget displays a bar or line indicating the map scale at the current zoom level.
Zoom in and out to see the scale bar update. Use the controls below to change the unit system
and visual style.
</p>

<div class="form-group">
<div class="spaced-row">
<label for="unit-select">Unit:</label>
<select id="unit-select" @bind="_unit">
<option value="@ScaleUnit.Imperial">Imperial (miles/feet)</option>
<option value="@ScaleUnit.Metric">Metric (km/m)</option>
<option value="@ScaleUnit.Dual">Dual (both)</option>
</select>
</div>
<div class="spaced-row">
<label for="style-select">Style:</label>
<select id="style-select" @bind="_style">
<option value="@ScaleBarWidgetStyle.Ruler">Ruler</option>
<option value="@ScaleBarWidgetStyle.Line">Line</option>
</select>
</div>
</div>

<MapView Longitude="-98.5" Latitude="39.8" Zoom="4" Class="map-view">
<Map>
<Basemap>
<BasemapStyle Name="BasemapStyleName.ArcgisTopographic" />
</Basemap>
</Map>
<ScaleBarWidget Position="OverlayPosition.BottomLeft"
Unit="@_unit"
Style="@_style" />
</MapView>

@code {
public override List<NavMenu.PageLink> PageLinks =>
[
new("https://developers.arcgis.com/javascript/latest/sample-code/widgets-scalebar/", "ArcGIS Maps SDK for JavaScript"),
new("https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar.html", "ScaleBar API Reference")
];

private ScaleUnit _unit = ScaleUnit.Imperial;
private ScaleBarWidgetStyle _style = ScaleBarWidgetStyle.Ruler;
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,18 @@ await InvokeAsync(async () =>
new("marker-rotation", "Marker Rotation", "oi-loop-circular", Category: Categories.Visualization),

new("widgets", "Widgets", "oi-location", Category: Categories.Widgets),
new("compass-widget", "Compass Widget", "oi-compass", Category: Categories.Widgets),
new("scale-bar-widget", "Scale Bar Widget", "oi-resize-width", Category: Categories.Widgets),
new("legends", "Legend", null, "legend.svg", Category: Categories.Widgets),
new("popups", "Popups", "oi-chat", Category: Categories.Widgets),
new("popup-actions", "Popup Actions", "oi-bullhorn", Category: Categories.Widgets),
new("bookmarks", "Bookmarks", "oi-bookmark", Category: Categories.Widgets),
new("layer-lists", "Layer Lists", "oi-list", Category: Categories.Widgets),
new("legends", "Legend", null, "legend.svg", Category: Categories.Widgets),
new("basemap-toggle-widget", "Basemap Toggle", "oi-loop", Category: Categories.Widgets),
new("basemap-layer-lists", "Basemap Layer Lists", "oi-spreadsheet", Category: Categories.Widgets),
new("locate-widget", "Locate Widget", "oi-target", Category: Categories.Widgets),
new("measurement-widgets", "Measurement Widgets", null, "ruler.svg", Category: Categories.Widgets),
new("search-multi-source", "Search Multiple Sources", "oi-magnifying-glass", Category: Categories.Widgets),
new("bookmarks", "Bookmarks", "oi-bookmark", Category: Categories.Widgets),

new("sql-query", "SQL Query", "oi-data-transfer-download", Category: Categories.Queries),
new("sql-filter-query", "SQL Filter", "oi-arrow-thick-bottom", Category: Categories.Queries),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,9 +1099,8 @@ a:not([href]):not([class]), a:not([href]):not([class]):hover {

/* Group headers */
.nav-list .nav-list-item.nav-group {
padding: 0;
margin-bottom: 0.25rem;
margin-top: 0.25rem;
padding: 0.25rem 0;
margin: 0;
background-color: transparent;
border-radius: 0;
border-top: 1px solid var(--background-grey-3);
Expand Down
1 change: 1 addition & 0 deletions samples/samples.cmdlineargs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"revision":3,"enabled":true,"preview":true,"root":{"items":[]}}
Loading