syncfusion/blazor-ui-components-skills / skills/syncfusion-blazor-maps
syncfusion-blazor-maps
VerifiedImplement interactive spatial data visualization with Syncfusion Maps component for Blazor. Use this skill when user needs to display geographic data, add markers/polygons to maps, integrate map providers (Google Maps, Bing Maps, Azure Maps, OpenStreetMap), create choropleth visualizations, handle user interactions with maps, export/print maps, support internationalization, implement accessibility features, or customize map styling and appearance.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 23.0 KB |
| references/accessibility.md | markdown | 9.9 KB |
| references/api-reference.md | markdown | 32.1 KB |
| references/customization-and-styling.md | markdown | 18.6 KB |
| references/data-visualization.md | markdown | 23.4 KB |
| references/events-and-methods.md | markdown | 28.1 KB |
| references/getting-started.md | markdown | 10.9 KB |
| references/internationalization-and-localization.md | markdown | 10.8 KB |
| references/map-providers.md | markdown | 16.8 KB |
| references/markers-and-layers.md | markdown | 27.3 KB |
| references/print-and-export.md | markdown | 13.0 KB |
| references/readme-security.md | markdown | 7.0 KB |
| references/security-review.md | markdown | 17.8 KB |
| references/spatial-features.md | markdown | 23.4 KB |
| references/state-persistence.md | markdown | 5.5 KB |
| references/user-interactions.md | markdown | 15.1 KB |
references/print-and-export.md
View on GitHub## Table of Contents
- [Security Warning](#security-warning)
- [Prerequisites for Export and Print (NEW - Important)](#prerequisites-for-export-and-print-new---important)
- [Exporting Maps](#exporting-maps)
- [Export as PNG](#export-as-png)
- [Export as SVG](#export-as-svg)
- [Export as PDF](#export-as-pdf)
- [Export Options](#export-options)
- [Print Functionality](#print-functionality)
- [Basic Print](#basic-print)
- [Custom Print Styling](#custom-print-styling)
- [Page Setup for Printing](#page-setup-for-printing)
- [Export with Legend and Labels](#export-with-legend-and-labels)
- [Including Map Elements](#including-map-elements)
- [Format Options Comparison](#format-options-comparison)
- [Export Workflow](#export-workflow)
- [Complete Export Example](#complete-export-example)
- [Troubleshooting Export Issues](#troubleshooting-export-issues)
- [Export dialog doesn't appear](#export-dialog-doesnt-appear)
- [Quality issues in exported image](#quality-issues-in-exported-image)
- [Export very slow](#export-very-slow)
# Print and Export
> **MANDATORY SECURITY NOTICE:** Export and print examples may reference third-party tiles or GeoJSON for illustration only. In production you MUST ensure exported content does not leak sensitive data. Recommended controls:
>
> - Host tiles and GeoJSON locally or serve via a validated server-side proxy that enforces allow-lists, HTTPS, content-type checks, schema validation, size/complexity limits, and property sanitization.
> - Require user authorization for export features and log all export actions for audit.
> - Apply watermarks or redaction for sensitive layers before export.
> - Sanitize labels, tooltips, and annotations (HTML-encode or strip markup) prior to including them in exported files.
> - NEVER export or forward raw `ShapeData`, tooltips, or annotation content to automated agents or LLMs without explicit schema validation and human sign-off.
>
## Prerequisites for Export and Print (NEW - Important)
Ensure the following properties are enabled on your `SfMaps` component:
```csharp
<SfMaps AllowImageExport="true" // Required for PNG/SVG export
AllowPdfExport="true" // Required for PDF export
AllowPrint="true"> // Required for printing
<!-- Map configuration -->
</SfMaps>
```
Without these properties set to `true`, export and print methods will not function.
**Security Recommendation:** Only enable these properties for authorized users:
```csharp
<SfMaps AllowImageExport="@IsUserAuthorized"
AllowPdfExport="@IsUserAuthorized"
AllowPrint="@IsUserAuthorized">
<!-- Map configuration -->
</SfMaps>
@code {
private bool IsUserAuthorized { get; set; }
protected override async Task OnInitializedAsync()
{
// Check user permissions
IsUserAuthorized = await AuthService.CanExportMaps();
}
}
```
---
## Exporting Maps
### Export as PNG
Export the current map view as PNG image:
```csharp
@page "/export-png"
@using Syncfusion.Blazor.Maps
<button @onclick="ExportAsPng">Export as PNG</button>
<SfMaps @ref="mapInstance" >
<MapsZoomSettings Enable="true" ZoomFactor="4"></MapsZoomSettings>
<MapsLayers>
<MapsLayer UrlTemplate="/tiles/{level}/{tileX}/{tileY}.png" TValue="string">
<MapsMarkerSettings>
<MapsMarker Visible="true" Datasource="@MarkerDataSource" TValue="MarkerData"
Width="15" Height="15">
</MapsMarker>
</MapsMarkerSettings>
</MapsLayer>
</MapsLayers>
</SfMaps>
@code {
private SfMaps mapInstance;
public class MarkerData
{
public double Latitude { get; set; }
public double Longitude { get; set; }
};
public List<MarkerData> MarkerDataSource = new List<MarkerData>
{
new MarkerData { Latitude = 47.60621, Longitude = -122.332071 }
};
private async Task ExportAsPng()
{
await mapInstance.ExportAsync(Syncfusion.Blazor.Maps.ExportType.PNG, "map-export");
}
}
```
The exported file is named `map-export.png` and downloads automatically.
### Export as SVG
SVG format preserves vector quality and is ideal for scaling:
```csharp
<button @onclick="ExportAsSvg">Export as SVG</button>
@code {
private async Task ExportAsSvg()
{
await mapInstance.ExportAsync(ExportType.SVG, "map-export");
}
}
```
SVG exports are crisp at any size and can be edited in vector design tools.
### Export as PDF
Export map as a PDF document with optional page orientation:
```csharp
<button @onclick="ExportAsPdfPortrait">Export as PDF (Portrait)</button>
<button @onclick="ExportAsPdfLandscape">Export as PDF (Landscape)</button>
@code {
private async Task ExportAsPdfPortrait()
{
// Export with Portrait orientation (default)
await mapInstance.ExportAsync(ExportType.PDF, "map-report", 0);
}
private async Task ExportAsPdfLandscape()
{
// Export with Landscape orientation
await mapInstance.ExportAsync(ExportType.PDF, "map-report", 1);
}
}
```
**PDF Orientation Options (NEW - Previously Missing):**
| Option | Description |
|--------|-------------|
| `PdfPageOrientation.Portrait` | Standard vertical page (8.5" x 11") |
| `PdfPageOrientation.Landscape` | Wide horizontal page (11" x 8.5") |
The PDF includes the map view at the time of export. Legends and labels are automatically included.
### Export Options
Control export parameters:
```csharp
@page "/export-advanced"
@using Syncfusion.Blazor.Maps
<button @onclick="export">Export</button>
<SfMaps @ref="Maps" AllowPdfExport="true">
<MapsLayers>
<MapsLayer ShapeData='new {dataOptions= "/data/world-map.json"}' TValue="string">
</MapsLayer>
</MapsLayers>
</SfMaps>
@code {
SfMaps Maps;
string exportString;
public async Task export()
{
exportString = await this.Maps.ExportAsync(Syncfusion.Blazor.Maps.ExportType.PDF, "Maps", 0, false);
Console.WriteLine(exportString);
}
}
```
## Print Functionality
### Basic Print
Print the map with browser print dialog:
```csharp
@page "/print-map"
@using Syncfusion.Blazor.Maps
@inject IJSRuntime JS
<button @onclick="PrintMap">Print Map</button>
<SfMaps @ref="mapInstance" AllowPrint="true">
<MapsLayers>
<MapsLayer UrlTemplate="/tiles/{level}/{tileX}/{tileY}.png" TValue="string">
</MapsLayer>
</MapsLayers>
</SfMaps>
@code {
private SfMaps mapInstance;
private async Task PrintMap()
{
await mapInstance.PrintAsync();
}
}
```
This opens the browser's print dialog. Users can select printer, page layout, and margins.
## Export with Legend and Labels
### Including Map Elements
```csharp
@page "/export-complete"
@using Syncfusion.Blazor.Maps
<button @onclick="ExportWithLegend">Export Map with Legend</button>
<SfMaps @ref="mapInstance" AllowImageExport="true">
<MapsLegendSettings Visible="true" Shape="Syncfusion.Blazor.Maps.LegendShape.Star" ShapeHeight="30" ShapeWidth="30" ShapePadding="10">
<MapsLegendShapeBorder Color="blue" Width="2">
</MapsLegendShapeBorder>
</MapsLegendSettings>
<MapsLayers>
<MapsLayer ShapeData='new {dataOptions ="/data/world-map.json"}' ShapeDataPath="Country"
DataSource="MemberShipDetails" ShapePropertyPath='new string[] {"name"}' TValue="UNCouncil">
<MapsDataLabelSettings Visible="true" LabelPath="name"></MapsDataLabelSettings>
<MapsShapeSettings ColorValuePath="Membership">
<MapsShapeColorMappings>
<MapsShapeColorMapping Value="Permanent" Color='new string[] {"#D84444"}' />
<MapsShapeColorMapping Value="Non-Permanent" Color='new string[] {"#316DB5"}' />
</MapsShapeColorMappings>
</MapsShapeSettings>
<MapsMarkerSettings>
<MapsMarker Visible="true" DataSource="MarkerData" Height="25" Width="15" TValue="City"
Shape="Syncfusion.Blazor.Maps.MarkerType.Image" ImageUrl="/images/ballon.png">
</MapsMarker>
</MapsMarkerSettings>
</MapsLayer>
</MapsLayers>
</SfMaps>
@code {
private SfMaps mapInstance;
public class City
{
public double Latitude { get; set; }
public double Longitude { get; set; }
}
public List<City> MarkerData = new List<City> {
new City { Latitude = 35.145083, Longitude = -117.960260 },
new City { Latitude = 40.724546, Longitude = -73.850344 },
new City { Latitude = 41.657782, Longitude = -91.533857 }
};
public class UNCouncil
{
public string Country { get; set; }
public string Membership { get; set; }
}
private List<UNCouncil> MemberShipDetails = new List<UNCouncil>
{
new UNCouncil { Country = "China", Membership = "Permanent" },
new UNCouncil { Country = "France", Membership = "Permanent" },
new UNCouncil { Country = "Russia", Membership = "Permanent" },
new UNCouncil { Country = "Kazakhstan", Membership = "Non-Permanent" },
new UNCouncil { Country = "Poland", Membership = "Non-Permanent" },
new UNCouncil { Country = "Sweden", Membership = "Non-Permanent" }
};
private async Task ExportWithLegend()
{
// Map exports automatically include visible legend and labels
await mapInstance.ExportAsync(Syncfusion.Blazor.Maps.ExportType.PNG, "map-with-legend");
}
}
```
## Format Options Comparison
| Format | Use Case | Pros | Cons |
|--------|----------|------|------|
| **PNG** | Web sharing, reports | Universal support, smaller file | Raster, loses quality when scaled |
| **SVG** | Printing, editing | Vector quality, editablein design tools | Larger file, limited browser support |
| **PDF** | Official documents, archiving | Portable, print-ready, preserves layout | Larger file size, fixed layout |
## Export Workflow
### Complete Export Example
```csharp
@page "/export-workflow"
@using Syncfusion.Blazor.Maps
<button @onclick="ExportWithPNG">PNG</button>
<button @onclick="ExportWithJPEG">JPEG</button>
<button @onclick="ExportWithSVG">SVG</button>
<SfMaps @ref="mapInstance" AllowImageExport="true" AllowPdfExport="true" AllowPrint="true">
<MapsLayers>
<MapsLayer ShapeData='new {dataOptions ="/data/world-map.json"}' ShapeDataPath="Country"
DataSource="MemberShipDetails" ShapePropertyPath='new string[] {"name"}' TValue="UNCouncil">
<MapsShapeSettings ColorValuePath="Membership">
<MapsShapeColorMappings>
<MapsShapeColorMapping Value="Permanent" Color='new string[] {"#D84444"}' />
<MapsShapeColorMapping Value="Non-Permanent" Color='new string[] {"#316DB5"}' />
</MapsShapeColorMappings>
</MapsShapeSettings>
<MapsMarkerSettings>
<MapsMarker Visible="true" DataSource="MarkerData" Height="25" Width="15" TValue="City" >
</MapsMarker>
</MapsMarkerSettings>
</MapsLayer>
</MapsLayers>
</SfMaps>
@code {
private SfMaps mapInstance;
public class City
{
public double Latitude { get; set; }
public double Longitude { get; set; }
}
public List<City> MarkerData = new List<City> {
new City { Latitude = 35.145083, Longitude = -117.960260 },
new City { Latitude = 40.724546, Longitude = -73.850344 },
new City { Latitude = 41.657782, Longitude = -91.533857 }
};
public class UNCouncil
{
public string Country { get; set; }
public string Membership { get; set; }
}
private List<UNCouncil> MemberShipDetails = new List<UNCouncil>
{
new UNCouncil { Country = "China", Membership = "Permanent" },
new UNCouncil { Country = "France", Membership = "Permanent" },
new UNCouncil { Country = "Russia", Membership = "Permanent" },
new UNCouncil { Country = "Kazakhstan", Membership = "Non-Permanent" },
new UNCouncil { Country = "Poland", Membership = "Non-Permanent" },
new UNCouncil { Country = "Sweden", Membership = "Non-Permanent" }
};
private async Task ExportWithPNG()
{
await mapInstance.ExportAsync(Syncfusion.Blazor.Maps.ExportType.PNG, "PNG");
}
private async Task ExportWithJPEG()
{
await mapInstance.ExportAsync(Syncfusion.Blazor.Maps.ExportType.JPEG, "JPEG");
}
private async Task ExportWithSVG()
{
await mapInstance.ExportAsync(Syncfusion.Blazor.Maps.ExportType.SVG, "SVG");
}
}
```
## Troubleshooting Export Issues
### Export dialog doesn't appear
- Verify map is fully rendered before export
- Check browser popup blockers aren't preventing download
- Ensure export method is awaited
### Quality issues in exported image
- PNG: Use higher zoom level before export for better quality
- SVG: Best quality output, consider for high-precision needs
- PDF: Use with legend included for complete document
### Export very slow
- Reduce map complexity (fewer markers, simpler shapes)
- Export smaller area rather than full globe
- Use PNG for faster export compared to SVG/PDF
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |