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

Fix and document solution for wsv error #167

Merged
merged 1 commit into from
May 13, 2023
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
34 changes: 24 additions & 10 deletions docs/pages/gettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,23 @@ nav_order: 2
```
6. In `Program.cs`, add the following line to your `builder.Services` to inject logic components like `GeometryEngine`.

```csharp
```csharp
builder.Services.AddGeoBlazor();
```
```

If you are using Blazor Server, you should also add the following lines to `Program.cs` to support the `.wsv` file type.

```csharp
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".wsv"] = "application/octet-stream";

app.UseStaticFiles();
// NOTE: for some reason, you still need the plain "UseStaticFiles" call above
app.UseStaticFiles(new StaticFileOptions
{
ContentTypeProvider = provider
});
```

7. Create a new Razor Component in the `Pages` folder, or just use `Index.razor`. Add a `MapView`. Give it basic

Expand Down Expand Up @@ -109,14 +123,14 @@ nav_order: 2
```
10. Add a Widget to the `MapView`, after the `WebMap`.

```html
<MapView Longitude="_longitude" Latitude="_latitude" Zoom="11" Style="height: 400px; width: 100%;">
<WebMap>
<PortalItem Id="4a6cb60ebbe3483a805999d481c2daa5" />
</WebMap>
<ScaleBarWidget Position="OverlayPosition.BottomLeft" />
</MapView>
```
```html
<MapView Longitude="_longitude" Latitude="_latitude" Zoom="11" Style="height: 400px; width: 100%;">
<WebMap>
<PortalItem Id="4a6cb60ebbe3483a805999d481c2daa5" />
</WebMap>
<ScaleBarWidget Position="OverlayPosition.BottomLeft" />
</MapView>
```
11. Run your application and make sure you can see your map!
![Web Map Sample](../assets/images/webmap.png)
12. Now that you have a great starting point, you can now start to customize the features available in your new app
Expand Down
8 changes: 8 additions & 0 deletions samples/dymaptic.GeoBlazor.Core.Sample.Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using dymaptic.GeoBlazor.Core;
using dymaptic.GeoBlazor.Core.Sample.Shared;
using Microsoft.AspNetCore.StaticFiles;


WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
Expand All @@ -26,7 +27,14 @@

app.UseHttpsRedirection();

var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".wsv"] = "application/octet-stream";

app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions // NOTE: for some reason, you still need the plain "UseStaticFiles" call above
{
ContentTypeProvider = provider
});

app.UseRouting();

Expand Down
2 changes: 1 addition & 1 deletion src/dymaptic.GeoBlazor.Core/Components/Views/SceneView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ await InvokeAsync(async () =>

await ViewJsModule!.InvokeVoidAsync("setAssetsPath", CancellationTokenSource.Token,
Configuration.GetValue<string?>("ArcGISAssetsPath",
"./_content/dymaptic.GeoBlazor.Core/assets"));
"/_content/dymaptic.GeoBlazor.Core/assets"));

await ViewJsModule!.InvokeVoidAsync("buildMapView",
CancellationTokenSource.Token, Id, DotNetObjectReference,
Expand Down
9 changes: 7 additions & 2 deletions src/dymaptic.GeoBlazor.Core/assetCopy.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
$SourceFiles = "./node_modules/@arcgis/core/assets/*"
$OutputDir = "./wwwroot/assets"
$packageJson = (Get-Content "package.json" -Raw) | ConvertFrom-Json
# read the version from package.json
$ArcGISVersion = $packageJson.dependencies."@arcgis/core"
# remove the ^ from the version
$ArcGISVersion = $ArcGISVersion.Replace("^", "")

If ((Get-Content "$OutputDir/ArcGISAssetsVersion.txt") -ne "4.26.5")
If ((Get-Content "$OutputDir/ArcGISAssetsVersion.txt") -ne $ArcGISVersion)
{
Write-Output "Deleting old assets"
Remove-Item './wwwroot/assets/*' -Recurse -Verbose
Expand All @@ -22,7 +27,7 @@ If ((Test-Path -Path './wwwroot/assets/*') -eq $false)
pause
}

Write-Output "4.26.5" | Out-File -FilePath "$OutputDir/ArcGISAssetsVersion.txt"
Write-Output $ArcGISVersion | Out-File -FilePath "$OutputDir/ArcGISAssetsVersion.txt"
}
Else
{
Expand Down
2 changes: 1 addition & 1 deletion src/dymaptic.GeoBlazor.Core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/dymaptic.GeoBlazor.Core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"author": "Tim Purdum",
"license": "ISC",
"dependencies": {
"@arcgis/core": "4.26.5",
"@arcgis/core": "^4.26.5",
"esbuild": "^0.17.5",
"protobufjs": "^7.2.2",
"protobufjs-cli": "^1.1.1"
Expand Down