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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 0 additions & 13 deletions CustomPopups/.idea/.idea.CustomPopups/.idea/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions CustomPopups/.idea/.idea.CustomPopups/.idea/encodings.xml

This file was deleted.

8 changes: 0 additions & 8 deletions CustomPopups/.idea/.idea.CustomPopups/.idea/indexLayout.xml

This file was deleted.

6 changes: 0 additions & 6 deletions CustomPopups/.idea/.idea.CustomPopups/.idea/misc.xml

This file was deleted.

6 changes: 0 additions & 6 deletions CustomPopups/.idea/.idea.CustomPopups/.idea/vcs.xml

This file was deleted.

21 changes: 21 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project>

<PropertyGroup>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<!--
By default, samples reference GeoBlazor NuGet packages with Version="*" (latest).
Set UseProjectReferences=true and configure the paths below to use local project references instead.
This is useful when developing GeoBlazor Core/Pro alongside the samples (e.g., as submodules).

Example usage:
dotnet build /p:UseProjectReferences=true /p:CoreProjectPath=../GeoBlazor/src/dymaptic.GeoBlazor.Core /p:ProProjectPath=../GeoBlazor.Pro/src/dymaptic.GeoBlazor.Pro
-->
<PropertyGroup Condition="'$(UseProjectReferences)' == 'true'">
<CoreProjectPath Condition="'$(CoreProjectPath)' == ''">$(MSBuildThisFileDirectory)..\GeoBlazor\src\dymaptic.GeoBlazor.Core</CoreProjectPath>
<ProProjectPath Condition="'$(ProProjectPath)' == ''">$(MSBuildThisFileDirectory)..\GeoBlazor.Pro\src\dymaptic.GeoBlazor.Pro</ProProjectPath>
</PropertyGroup>

</Project>
88 changes: 87 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,87 @@
# GeoBlazor-Samples
# GeoBlazor Samples

Sample applications and projects demonstrating [GeoBlazor](https://github.com/dymaptic/GeoBlazor) - a Blazor component library for ArcGIS Maps SDK for JavaScript.

## Repository Structure

### `samples/` - Library Samples

Built-in sample applications that ship with GeoBlazor Core and Pro. These demonstrate the full range of components and features.

- **`samples/core/`** - GeoBlazor Core samples
- `dymaptic.GeoBlazor.Core.Sample.Shared` - Shared sample pages and components
- `dymaptic.GeoBlazor.Core.Sample.Wasm` - Standalone WebAssembly sample runner
- `dymaptic.GeoBlazor.Core.Sample.WebApp` - Blazor Web App sample runner (Server + WASM)
- `dymaptic.GeoBlazor.Core.Sample.Maui` - MAUI hybrid sample runner
- `dymaptic.GeoBlazor.Core.Sample.OAuth` - OAuth authentication sample
- `dymaptic.GeoBlazor.Core.Sample.TokenRefresh` - Token refresh pattern sample

- **`samples/pro/`** - GeoBlazor Pro samples
- `dymaptic.GeoBlazor.Pro.Sample.Shared` - Shared Pro sample pages and components
- `dymaptic.GeoBlazor.Pro.Sample.Wasm` - Standalone WebAssembly Pro sample runner
- `dymaptic.GeoBlazor.Pro.Sample.WebApp` - Blazor Web App Pro sample runner (Server + WASM)
- `dymaptic.GeoBlazor.Pro.Sample.Maui` - MAUI hybrid Pro sample runner

### `projects/` - Full Project Examples

Real-world example applications built with GeoBlazor:

- **CustomPopups** - Custom popup functionality
- **CustomPopupsJS** - Custom popups with JavaScript integration
- **DesMoineBusRoutes** - Bus route mapping
- **MuseumsOfChicago** - Museum location finder
- **NationFinder** / **NationFinder2** - Country search applications
- **PointsOnAMapBlog** - Points of interest mapping
- **ShipmentTracker** - Shipment tracking
- **SolarTracker** - Solar panel location tracking

## Getting Started

### Using NuGet Packages (Default)

By default, samples reference the latest GeoBlazor NuGet packages (`Version="*"`).

```bash
# Run a Core sample
cd samples/core/dymaptic.GeoBlazor.Core.Sample.Wasm
dotnet run

# Run a Pro sample (requires Pro license)
cd samples/pro/dymaptic.GeoBlazor.Pro.Sample.Wasm
dotnet run

# Run a project example
cd projects/DesMoineBusRoutes
dotnet run
```

### Using Local Project References

To develop against local GeoBlazor source code, set `UseProjectReferences=true` and configure the project paths:

```bash
dotnet build /p:UseProjectReferences=true \
/p:CoreProjectPath=../GeoBlazor/src/dymaptic.GeoBlazor.Core \
/p:ProProjectPath=../GeoBlazor.Pro/src/dymaptic.GeoBlazor.Pro
```

Default project paths (when not explicitly set) assume sibling directories:
- `CoreProjectPath` -> `../GeoBlazor/src/dymaptic.GeoBlazor.Core`
- `ProProjectPath` -> `../GeoBlazor.Pro/src/dymaptic.GeoBlazor.Pro`

## Configuration

Most samples require an ArcGIS API key. Add it to `appsettings.json` or user secrets:

```json
{
"ArcGISApiKey": "YOUR_API_KEY"
}
```

Pro samples additionally require a GeoBlazor Pro license key.

## Related Repositories

- [GeoBlazor (Core)](https://github.com/dymaptic/GeoBlazor) - Open-source Blazor mapping library
- [GeoBlazor Pro](https://github.com/dymaptic/GeoBlazor.Pro) - Commercial extension with 3D support and advanced features
3 changes: 2 additions & 1 deletion nuget.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="LocalPackages" value=".\packages" />
</packageSources>
</configuration>
</configuration>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions samples/core/dymaptic.GeoBlazor.Core.Sample.Maui/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>

<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="dymaptic.GeoBlazor.Core.Sample.Maui.App">
<Application.Resources>
<ResourceDictionary>

<Color x:Key="PageBackgroundColor">#512bdf</Color>
<Color x:Key="PrimaryTextColor">White</Color>

<Style TargetType="Label">
<Setter Property="TextColor" Value="{DynamicResource PrimaryTextColor}" />
<Setter Property="FontFamily" Value="OpenSansRegular" />
</Style>

<Style TargetType="Button">
<Setter Property="TextColor" Value="{DynamicResource PrimaryTextColor}" />
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="BackgroundColor" Value="#2b0b98" />
<Setter Property="Padding" Value="14,10" />
</Style>

</ResourceDictionary>
</Application.Resources>
</Application>
32 changes: 32 additions & 0 deletions samples/core/dymaptic.GeoBlazor.Core.Sample.Maui/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.Extensions.Configuration;


namespace dymaptic.GeoBlazor.Core.Sample.Maui;

public partial class App
{
public App(IConfiguration configuration)
{
_configuration = configuration;
InitializeComponent();
}

protected override void OnSleep()
{
string? apiKey = _configuration.GetValue<string?>("ArcGISApiKey", null);

if (!string.IsNullOrWhiteSpace(apiKey))
{
Preferences.Set("ArcGISApiKey", apiKey);
}

base.OnSleep();
}

protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(new MainPage()) { Title = "GeoBlazor Samples" };
}

private readonly IConfiguration _configuration;
}
46 changes: 46 additions & 0 deletions samples/core/dymaptic.GeoBlazor.Core.Sample.Maui/Main.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<Router AppAssembly="@typeof(App).Assembly"
AdditionalAssemblies="@(new[] { typeof(MainLayout).Assembly })">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>

@code {

protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
await CheckAndRequestLocationPermission();
}

private async Task CheckAndRequestLocationPermission()
{
if (DeviceInfo.Platform == DevicePlatform.WinUI) return;

PermissionStatus status = await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();

if (status == PermissionStatus.Granted) return;

if ((status == PermissionStatus.Denied) && (DeviceInfo.Platform == DevicePlatform.iOS))
{
// Prompt the user to turn on in settings
// On iOS once a permission has been denied it may not be requested again from the application
return;
}

if (Permissions.ShouldShowRationale<Permissions.LocationWhenInUse>())
{
// Prompt the user with additional information as to why the permission is needed
}

await Permissions.RequestAsync<Permissions.LocationWhenInUse>();
}

}
15 changes: 15 additions & 0 deletions samples/core/dymaptic.GeoBlazor.Core.Sample.Maui/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:dymaptic.GeoBlazor.Core.Sample.Maui"
x:Class="dymaptic.GeoBlazor.Core.Sample.Maui.MainPage"
BackgroundColor="{DynamicResource PageBackgroundColor}">

<BlazorWebView x:Name="BlazorWebView" HostPage="wwwroot/index.html">
<BlazorWebView.RootComponents>
<RootComponent Selector="#app" ComponentType="{x:Type local:Main}" />
</BlazorWebView.RootComponents>
</BlazorWebView>

</ContentPage>
13 changes: 13 additions & 0 deletions samples/core/dymaptic.GeoBlazor.Core.Sample.Maui/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace dymaptic.GeoBlazor.Core.Sample.Maui;

public partial class MainPage
{
public MainPage()
{
InitializeComponent();

#if ANDROID26_0_OR_GREATER
BlazorWebView.BlazorWebViewInitialized += OnBlazorWebViewInitialized;
#endif
}
}
42 changes: 42 additions & 0 deletions samples/core/dymaptic.GeoBlazor.Core.Sample.Maui/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Microsoft.Extensions.Configuration;
using System.Reflection;


namespace dymaptic.GeoBlazor.Core.Sample.Maui;

public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
MauiAppBuilder builder = MauiApp.CreateBuilder();

builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});

builder.Services.AddMauiBlazorWebView();
#if DEBUG
builder.Services.AddBlazorWebViewDeveloperTools();
#endif

builder.Services.AddScoped<HttpClient>();
builder.Configuration.AddInMemoryCollection();

var executingAssembly = Assembly.GetExecutingAssembly();

using Stream stream = executingAssembly
.GetManifestResourceStream("dymaptic.GeoBlazor.Core.Sample.Maui.appsettings.json")!;

IConfigurationRoot config = new ConfigurationBuilder()
.AddUserSecrets(executingAssembly)
.AddJsonStream(stream)
.Build();
builder.Configuration.AddConfiguration(config);
builder.Services.AddGeoBlazor(builder.Configuration);

return builder.Build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@drawable/icon"
android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Android.App;
using Android.Content.PM;


namespace dymaptic.GeoBlazor.Core.Sample.Maui;

[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, Icon = "@drawable/icon",
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode |
ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
}
Loading