### Install BlazorLeaflet package Source: https://github.com/mehigh17/blazorleaflet/blob/master/README.md Use the .NET CLI to add the BlazorLeaflet package to your project. ```bash dotnet add package BlazorLeaflet ``` -------------------------------- ### Bind map parameters Source: https://github.com/mehigh17/blazorleaflet/blob/master/README.md Initialize the Map object and starting coordinates in your C# code. ```csharp private Map _map = new Map(jsRuntime); private PointF _startAt = new PointF(47.5574007f, 16.3918687f); ``` -------------------------------- ### TileLayer Subdomains Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1TileLayer.html Defines the subdomains for the tile service. Example shows initialization with a single subdomain. ```csharp string [] BlazorLeaflet.Models.TileLayer.Subdomains = new string [] { "abc" } ``` -------------------------------- ### Configure and Add Marker with Icon, Tooltip, and Popup Source: https://context7.com/mehigh17/blazorleaflet/llms.txt Create and configure a Marker with custom icon, tooltip, and popup. Handles marker events like click and drag, updating its position and popup content. ```csharp using System.Drawing; using BlazorLeaflet.Models; using BlazorLeaflet.Models.Events; // Create a basic marker var marker = new Marker(47.5574007f, 16.3918687f) { Title = "Vienna", Draggable = true, Opacity = 1.0, RiseOnHover = true }; // Add custom icon marker.Icon = new Icon { Url = "images/custom-marker.png", Size = new Size(32, 32), Anchor = new Point(16, 32), PopupAnchor = new Point(0, -32) }; // Add tooltip (shown on hover) marker.Tooltip = new Tooltip { Content = "Hover tooltip content", Direction = "top", IsPermanent = false, IsSticky = false, Opacity = 0.9 }; // Add popup (shown on click) marker.Popup = new Popup { Content = "Vienna
Capital of Austria", MaximumWidth = 300, MinimumWidth = 50, AutoPanEnabled = true, ShowCloseButton = true }; // Handle marker events marker.OnClick += (sender, e) => { Console.WriteLine($"Marker clicked at {e.LatLng.Lat}, {e.LatLng.Lng}"); }; marker.OnDrag += (sender, e) => { Console.WriteLine($"Dragging to {e.LatLng.Lat}, {e.LatLng.Lng}"); }; marker.OnDragEnd += (sender, e) => { marker.Position = e.LatLng; marker.Popup.Content = $"Moved to {e.LatLng.Lat:0.00}, {e.LatLng.Lng:0.00}"; await LeafletInterops.UpdatePopupContent(jsRuntime, _map.Id, marker); }; _map.AddLayer(marker); ``` -------------------------------- ### BlazorLeaflet Models Overview Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1Tooltip-members.html Overview of the Layer model and its associated properties and event handlers. ```APIDOC ## BlazorLeaflet.Models.Layer ### Description The Layer class serves as the base model for map layers in BlazorLeaflet, supporting Tooltips and Popups. ### Properties - **Opacity** (float) - Controls the transparency of the layer. - **Pane** (string) - The map pane where the layer is rendered. - **Popup** (Popup) - Associated popup content for the layer. - **Tooltip** (Tooltip) - Associated tooltip content for the layer. ### Event Handlers - **PopupEventHandler**(Layer sender, PopupEvent e) - Triggered when a popup event occurs on the layer. - **TooltipEventHandler**(Layer sender, TooltipEvent e) - Triggered when a tooltip event occurs on the layer. ``` -------------------------------- ### Map Methods Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Map.html Core methods for managing layers and initializing the map. ```APIDOC ## Map Methods ### AddLayer - **Description**: Adds a layer to the map. - **Parameters**: - **layer** (Layer) - Required - The layer to be added. - **Exceptions**: - System.ArgumentNullException: Throws when the layer is null. - UninitializedMapException: Throws when the map has not been yet initialized. ### GetLayers - **Description**: Retrieves a read-only collection of the current layers on the map. - **Returns**: IReadOnlyCollection - A read-only collection of layers. ### RaiseOnInitialized - **Description**: This method MUST be called only once by the Blazor component upon rendering, and never by the user. ### RemoveLayer - **Description**: Removes a layer from the map. - **Parameters**: - **layer** (Layer) - Required - The layer to be removed. - **Exceptions**: - System.ArgumentNullException: Throws when the layer is null. - UninitializedMapException: Throws when the map has not been yet initialized. ``` -------------------------------- ### Create a Circle Layer Source: https://context7.com/mehigh17/blazorleaflet/llms.txt Draws a circle with a center point and radius in meters, supporting dynamic updates. ```csharp using BlazorLeaflet.Models; var circle = new Circle { Position = new LatLng(51.508f, -0.11f), Radius = 500f, // Radius in meters DrawStroke = true, StrokeColor = Color.Green, StrokeWidth = 2, Fill = true, FillColor = Color.LightGreen, FillOpacity = 0.4, Tooltip = new Tooltip { Content = "500m radius zone" } }; // Update circle radius dynamically circle.Radius = 1000f; await LeafletInterops.UpdateShape(jsRuntime, _map.Id, circle); _map.AddLayer(circle); ``` -------------------------------- ### Reference interop script Source: https://github.com/mehigh17/blazorleaflet/blob/master/README.md Include the required JavaScript interop file in your HTML head section. ```html ``` -------------------------------- ### Initialize map component Source: https://github.com/mehigh17/blazorleaflet/blob/master/README.md Wrap the LeafletMap component in a container with defined dimensions. ```html
``` -------------------------------- ### BlazorLeaflet Models Reference Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1Polygon-members.html Overview of the properties and event handlers for BlazorLeaflet models. ```APIDOC ## BlazorLeaflet Models Reference ### Description This section details the properties and event handlers available for various BlazorLeaflet models, including Polyline, Path, and Layer. ### Properties - **Shape** (Polyline) - Defines the shape configuration. - **SmoothFactory** (Polyline) - Factory for smoothing polyline shapes. - **StrokeColor** (Path) - The color of the stroke. - **StrokeDashArray** (Path) - A string that defines the stroke dash pattern. - **StrokeDashOffset** (Path) - The offset of the stroke dash pattern. - **StrokeOpacity** (Path) - The opacity of the stroke. - **StrokeWidth** (Path) - The width of the stroke in pixels. - **Tooltip** (Layer) - The tooltip associated with the layer. ### Event Handlers - **TooltipEventHandler** (Layer) - Delegate: (Layer sender, TooltipEvent e). Handles tooltip events for layers. ``` -------------------------------- ### Including Open Iconic with Foundation Source: https://github.com/mehigh17/blazorleaflet/blob/master/BlazorLeaflet/BlazorLeaflet.Samples/wwwroot/css/open-iconic/README.md Link to the Foundation stylesheet for Open Iconic. This enables the use of 'fi' prefixed classes for icons. ```html ``` ```html ``` -------------------------------- ### Create a Polyline Layer Source: https://context7.com/mehigh17/blazorleaflet/llms.txt Connects multiple coordinate points with line segments. ```csharp using System.Drawing; using BlazorLeaflet.Models; var polyline = new Polyline { Shape = new[] { new[] { new PointF(45.51f, -122.68f), new PointF(37.77f, -122.43f), new PointF(34.04f, -118.2f) } }, DrawStroke = true, StrokeColor = Color.Purple, StrokeWidth = 4, StrokeOpacity = 0.8, SmoothFactory = 1.0, // Line simplification factor NoClipEnabled = false, Tooltip = new Tooltip { Content = "West Coast Route" } }; _map.AddLayer(polyline); ``` -------------------------------- ### Add marker to map Source: https://github.com/mehigh17/blazorleaflet/blob/master/README.md Create a marker with a tooltip and icon, then add it to the map layers. ```csharp // Create the marker var marker = new Marker(0.23f, 32f); marker.Tooltip = new Tooltip { Content = "This is a nice location!" }; marker.Icon = new Icon { Url = "... some url" }; // Add it to the layers collection _map.AddLayer(marker); ``` -------------------------------- ### Tooltip Event Handling Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1DivOverlay-members.html Details on how to handle tooltip events for layers within the BlazorLeaflet library. ```APIDOC ## TooltipEventHandler ### Description This event handler is used to manage tooltip events associated with a Layer in BlazorLeaflet. It is defined within the BlazorLeaflet.Models.Layer class. ### Method TooltipEventHandler ### Endpoint N/A (This is a callback/event handler signature, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp // Example usage within a Blazor component: // Assuming 'myLayer' is an instance of BlazorLeaflet.Models.Layer myLayer.TooltipEventHandler = (sender, e) => { // Handle tooltip event logic here Console.WriteLine("Tooltip event triggered!"); }; ``` ### Response #### Success Response (N/A) This is an event handler, not an API endpoint that returns a response. #### Response Example N/A ``` -------------------------------- ### BlazorLeaflet.Utils Namespace Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/namespaceBlazorLeaflet_1_1Utils.html Overview of the classes available within the BlazorLeaflet.Utils namespace. ```APIDOC ## BlazorLeaflet.Utils Namespace ### Description The BlazorLeaflet.Utils namespace provides utility functionality to support the BlazorLeaflet component library. ### Classes - **StringHelper** (class) - Provides string manipulation utilities for the library. ``` -------------------------------- ### Blazor Leaflet Interactive Map Demo Source: https://context7.com/mehigh17/blazorleaflet/llms.txt This Blazor component demonstrates a complete interactive map with features like adding markers, fitting bounds to markers, clearing markers, and displaying map center and zoom information. It requires BlazorLeaflet and System.Drawing namespaces. ```csharp @page "/map-demo" @using System.Drawing @using BlazorLeaflet @using BlazorLeaflet.Models @using BlazorLeaflet.Models.Events @inject IJSRuntime jsRuntime

Interactive Map Demo

Center: @_centerLat.ToString("F4"), @_centerLng.ToString("F4") Zoom: @_zoom.ToString("F1")
@code { private Map _map; private List _markers = new List(); private float _centerLat, _centerLng, _zoom; protected override void OnInitialized() { _map = new Map(jsRuntime) { Center = new LatLng(40.7128f, -74.0060f), Zoom = 12f, MinZoom = 2f, MaxZoom = 18f }; _map.OnInitialized += async () => { // Add base tile layer _map.AddLayer(new TileLayer { UrlTemplate = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", Attribution = "© OpenStreetMap contributors" }); // Add sample polygon _map.AddLayer(new Polygon { Shape = new[] { new[] { new PointF(40.72f, -74.01f), new PointF(40.73f, -74.00f), new PointF(40.72f, -73.99f), new PointF(40.71f, -74.00f) }}, Fill = true, FillColor = Color.FromArgb(100, 0, 100, 255), StrokeColor = Color.Blue, Popup = new Popup { Content = "Downtown Area" } }); await UpdateMapInfo(); }; _map.OnMoveEnd += async (s, e) => await UpdateMapInfo(); _map.OnZoomEnd += async (s, e) => await UpdateMapInfo(); _map.OnClick += (sender, e) => { AddMarkerAt(e.LatLng); }; } private async Task UpdateMapInfo() { var center = await _map.GetCenter(); _centerLat = center.Lat; _centerLng = center.Lng; _zoom = await _map.GetZoom(); StateHasChanged(); } private async Task AddMarkerAtCenter() { var center = await _map.GetCenter(); AddMarkerAt(center); } private void AddMarkerAt(LatLng position) { var marker = new Marker(position) { Draggable = true, Popup = new Popup { Content = $"Marker at {position.Lat:F4}, {position.Lng:F4}" }, Tooltip = new Tooltip { Content = "Drag me!" } }; marker.OnDragEnd += (s, e) => { marker.Position = e.LatLng; marker.Popup.Content = $"Moved to {e.LatLng.Lat:F4}, {e.LatLng.Lng:F4}"; LeafletInterops.UpdatePopupContent(jsRuntime, _map.Id, marker); }; _markers.Add(marker); _map.AddLayer(marker); } private void FitToMarkers() { if (_markers.Count >= 2) { var minLat = _markers.Min(m => m.Position.Lat); var maxLat = _markers.Max(m => m.Position.Lat); var minLng = _markers.Min(m => m.Position.Lng); var maxLng = _markers.Max(m => m.Position.Lng); _map.FitBounds( new PointF(minLat, minLng), new PointF(maxLat, maxLng), padding: new PointF(50f, 50f) ); } } private void ClearMarkers() { foreach (var marker in _markers) { _map.RemoveLayer(marker); } _markers.Clear(); } } ``` -------------------------------- ### Create an Image Overlay Layer Source: https://context7.com/mehigh17/blazorleaflet/llms.txt Overlays an image onto a specific geographic region defined by two corner coordinates. ```csharp using System.Drawing; using BlazorLeaflet.Models; var imageOverlay = new ImageLayer( url: "https://example.com/historical-map.png", corner1: new PointF(40.712f, -74.227f), // Southwest corner corner2: new PointF(40.774f, -74.125f) // Northeast corner ) { Opacity = 0.7f, Alt = "Historical map overlay", zIndex = 1, ClassName = "map-overlay" }; _map.AddLayer(imageOverlay); ``` -------------------------------- ### Using Open Iconic Standalone Source: https://github.com/mehigh17/blazorleaflet/blob/master/BlazorLeaflet/BlazorLeaflet.Samples/wwwroot/css/open-iconic/README.md Link to the default Open Iconic stylesheet for standalone usage. Use 'oi' prefixed classes with the 'data-glyph' attribute. ```html ``` ```html ``` -------------------------------- ### BlazorLeaflet Map Methods Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Map-members.html This section details various methods available in the BlazorLeaflet Map class. ```APIDOC ## RaiseOnInitialized ### Description This method is related to the initialization event of the map. ### Method (Implicitly called during initialization) ### Endpoint N/A (Class method) ### Parameters None ### Request Example N/A ### Response N/A ## RemoveLayer ### Description Removes a specified layer from the map. ### Method (Implicitly called) ### Endpoint N/A (Class method) ### Parameters #### Path Parameters - **layer** (Layer) - Required - The layer object to remove. ### Request Example N/A ### Response N/A ## Zoom ### Description This property or method is related to controlling or getting the zoom level of the map. ### Method (Likely GET or SET depending on context) ### Endpoint N/A (Class property/method) ### Parameters None explicitly defined in this snippet. ### Request Example N/A ### Response N/A ``` -------------------------------- ### BlazorLeaflet Exceptions Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/annotated.html Documentation for custom exceptions thrown by the BlazorLeaflet library. ```APIDOC ## BlazorLeaflet Exceptions ### Description Custom exception types used within the BlazorLeaflet library to indicate specific error conditions. ### Exception Classes - **UninitializedMapException**: Thrown when an operation is attempted on a map before it has been fully initialized. ``` -------------------------------- ### Including Open Iconic with Bootstrap Source: https://github.com/mehigh17/blazorleaflet/blob/master/BlazorLeaflet/BlazorLeaflet.Samples/wwwroot/css/open-iconic/README.md Link to the Bootstrap stylesheet for Open Iconic. This enables the use of 'oi' prefixed classes for icons. ```html ``` ```html ``` -------------------------------- ### Create a Rectangle Layer Source: https://context7.com/mehigh17/blazorleaflet/llms.txt Draws a rectangular overlay using a RectangleF bounds structure. ```csharp using System.Drawing; using BlazorLeaflet.Models; var rectangle = new Rectangle { // RectangleF(X, Y, Width, Height) where X=Lat, Y=Lng Shape = new RectangleF(10f, 0f, 5f, 10f), DrawStroke = true, StrokeColor = Color.Red, StrokeWidth = 2, StrokeDashArray = "5, 10", // Dashed line pattern Fill = true, FillColor = Color.FromArgb(128, 255, 0, 0), // Semi-transparent red FillOpacity = 0.3, Popup = new Popup { Content = "Restricted Area" } }; _map.AddLayer(rectangle); ``` -------------------------------- ### Configure LeafletMap Component Source: https://context7.com/mehigh17/blazorleaflet/llms.txt Render a map using the LeafletMap component and configure its properties like center, zoom, and controls. Ensure the container has explicit dimensions. ```csharp @using BlazorLeaflet @using BlazorLeaflet.Models @inject IJSRuntime jsRuntime
@code { private Map _map; protected override void OnInitialized() { _map = new Map(jsRuntime) { Center = new LatLng(47.5574007f, 16.3918687f), Zoom = 4.8f, MinZoom = 2f, MaxZoom = 18f, ZoomControl = true }; _map.OnInitialized += () => { // Add layers after map is initialized _map.AddLayer(new TileLayer { UrlTemplate = "https://a.tile.openstreetmap.org/{z}/{x}/{y}.png", Attribution = "© OpenStreetMap contributors" }); }; } } ``` -------------------------------- ### BlazorLeaflet _Imports Class Reference Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1__Imports.html Reference for the _Imports class within the BlazorLeaflet namespace. ```APIDOC ## BlazorLeaflet._Imports Class Reference ### Description This class appears to be an internal import class for the BlazorLeaflet library, likely generated during the build process. ### Protected Member Functions - **Execute** (void) - **Execute** (void) ### Source File - BlazorLeaflet/BlazorLeaflet/obj/Debug/netstandard2.0/Razor/_Imports.razor.g.cs ``` -------------------------------- ### Marker Constructors Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1Marker.html Constructors available for the BlazorLeaflet.Models.Marker class. ```APIDOC ## Marker Constructors ### Marker(float x, float y) Creates a new Marker instance with the specified x and y coordinates. ### Marker(PointF position) Creates a new Marker instance with the specified position. ### Marker(LatLng latLng) Creates a new Marker instance with the specified LatLng coordinates. ``` -------------------------------- ### BlazorLeaflet.Models.Layer Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1GridLayer-members.html Properties and event handlers for the base Layer model. ```APIDOC ## Layer Properties and Events ### Description Base class for map layers including tooltip functionality. ### Properties - **Tooltip** - Configuration for the layer's tooltip. ### Events - **TooltipEventHandler(Layer sender, TooltipEvent e)** - Event handler triggered by tooltip interactions. ``` -------------------------------- ### TooltipEvent Class Reference Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1Events_1_1TooltipEvent.html Details the properties available in the TooltipEvent class, which inherits from the base Event class. ```APIDOC ## TooltipEvent Class ### Description Represents an event associated with a tooltip in the BlazorLeaflet component. ### Properties - **Tooltip** (Tooltip) - Gets or sets the tooltip object associated with the event. - **Type** (string) - Inherited from Event; gets or sets the type of the event. ``` -------------------------------- ### ImageLayer Model Properties Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1ImageLayer.html Overview of the properties available for the ImageLayer model. ```APIDOC ## ImageLayer Properties ### Description Defines the configuration for an image overlay on the map. ### Properties - **Alt** (string) - Text for the alt attribute of the image (accessibility). - **zIndex** (int) - The explicit zIndex of the overlay layer. - **ClassName** (string) - A custom class name to assign to the image. - **Url** (string) - The image source URL. - **Corner1** (PointF) - First corner coordinate. - **Corner2** (PointF) - Second corner coordinate. ### Inherited Properties (InteractiveLayer) - **IsInteractive** (bool) - If false, the layer will not emit mouse events. - **IsBubblingMouseEvents** (bool) - If true, mouse events bubble up to the map. ### Inherited Properties (Layer) - **Id** (string) - Unique identifier for the layer. - **Pane** (string) - The map pane where the layer is rendered. - **Attribution** (string) - Attribution text for the layer. - **Tooltip** (Tooltip) - Tooltip assigned to the layer. - **Popup** (Popup) - Popup shown when the layer is clicked. ``` -------------------------------- ### BlazorLeaflet Core Classes Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/annotated.html This section details the core classes provided by BlazorLeaflet for map manipulation and interaction. ```APIDOC ## BlazorLeaflet Core Classes ### Description Core classes for BlazorLeaflet, including map objects, layers, and utility functions. ### Classes - **LeafletMap**: Represents the main Leaflet map object in Blazor. - **Map**: Alias for LeafletMap. - **Layer**: Base class for all map layers. - **GridLayer**: Represents a layer that displays a grid of tiles. - **TileLayer**: A specific type of GridLayer for displaying map tiles. - **ImageLayer**: A layer for displaying a single image on the map. - **Marker**: Represents an icon placed on the map at a specific location. - **Circle**: Represents a circle drawn on the map. - **Rectangle**: Represents a rectangle drawn on the map. - **Polygon**: Represents a polygon drawn on the map. - **Polyline**: Represents a polyline drawn on the map. - **Icon**: Represents an icon used for markers. - **LatLng**: Represents a geographical coordinate (latitude and longitude). - **DivOverlay**: Base class for overlays that use HTML elements (like Popups and Tooltips). - **Popup**: An overlay that can be attached to a marker or map. - **Tooltip**: An overlay that displays a small text label, often on hover. - **InteractiveLayer**: Base class for layers that can be interacted with (e.g., clicked, hovered). - **MbTilesLayer**: A layer for displaying tiles from MBTiles files (requires Leaflet.TileLayer.MBTiles plugin). - **ShapefileLayer**: A layer for displaying shapefiles (requires Leaflet.Shapefile plugin). ### Utilities - **StringHelper**: Utility class for string manipulation. ``` -------------------------------- ### BlazorLeaflet.Models.Popup Class Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1Popup.html Configuration properties for the Popup model in BlazorLeaflet. ```APIDOC ## BlazorLeaflet.Models.Popup ### Description The Popup class represents a popup overlay on a Leaflet map. It provides various properties to control its size, positioning, and user interaction behavior. ### Properties - **MaximumWidth** (int) - Max width of the popup, in pixels (default: 300). - **MinimumWidth** (int) - Min width of the popup, in pixels (default: 50). - **MaximumHeight** (int?) - If set, creates a scrollable container of the given height inside a popup if its content exceeds it. - **AutoPanEnabled** (bool) - Set to false to disable map panning animation to fit the opened popup (default: true). - **AutoPanPaddingTopLeft** (Point?) - The margin between the popup and the top left corner of the map view after auto-panning. - **AutoPanPaddingBottomLeft** (Point?) - The margin between the popup and the bottom right corner of the map view after auto-panning. - **AutoPanPadding** (Point) - Equivalent of setting both top left and bottom right auto-pan padding to the same value (default: new Point(5, 5)). - **KeepInView** (bool) - Set to true to prevent users from panning the popup off of the screen while it is open. - **ShowCloseButton** (bool) - Controls the presence of a close button in the popup (default: true). - **AutoClose** (bool) - Set to false to override the default behavior of the popup closing when another popup is opened (default: true). - **CloseOnEscapeKey** (bool) - Set to false to override the default behavior of the ESC key for closing the popup (default: true). - **Content** (string) - The content of the popup. ``` -------------------------------- ### Layer Lifecycle and Interaction Hooks Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1ImageLayer-members.html Hooks for handling layer lifecycle events and user interactions. ```APIDOC ## Layer Lifecycle and Interaction Hooks ### Description These hooks allow developers to respond to layer lifecycle changes and user input events. ### Hooks - **OnAdd**: Triggered when a layer is added to the map. - **OnClick**: Triggered on a mouse click event. - **OnContextMenu**: Triggered on a context menu event. - **OnDblClick**: Triggered on a double-click event. - **OnMouseDown**: Triggered when a mouse button is pressed. - **OnMouseOut**: Triggered when the mouse leaves the layer. - **OnMouseOver**: Triggered when the mouse enters the layer. - **OnMouseUp**: Triggered when a mouse button is released. - **OnPopupClose / OnPopupOpen**: Lifecycle hooks for popup visibility. - **OnRemove**: Triggered when a layer is removed. - **OnTooltipClose / OnTooltipOpen**: Lifecycle hooks for tooltip visibility. ``` -------------------------------- ### Tooltip Event Handlers Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1ShapefileLayer.html The ShapefileLayer class supports event handlers for tooltip open and close events. ```APIDOC ## Tooltip Event Handlers ### Description Handles events related to the tooltip associated with a shapefile layer. ### Events - **OnTooltipOpen**: Triggered when the tooltip for a shapefile layer is opened. - **OnTooltipClose**: Triggered when the tooltip for a shapefile layer is closed. ``` -------------------------------- ### BlazorLeaflet.Models.Events.Event Class Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1Events_1_1Event.html Reference documentation for the Event class used within the BlazorLeaflet library. ```APIDOC ## Class: BlazorLeaflet.Models.Events.Event ### Description The Event class is a base model used for handling events within the BlazorLeaflet component library. It is defined in the namespace BlazorLeaflet.Models.Events. ### Properties - **Type** (string) - Gets or sets the type of the event. ``` -------------------------------- ### Popup Configuration Properties Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1Popup.html This section details the configurable properties of the BlazorLeaflet Popup component. ```APIDOC ## Popup Properties This section describes the properties available for configuring the `Popup` component in BlazorLeaflet. ### AutoPanPadding - **Type**: `Point` - **Default**: `new Point(5, 5)` - **Description**: Equivalent of setting both top left and bottom right autopan padding to the same value. This controls the margin between the popup and the map edges when the map pans to fit the popup. ### AutoPanPaddingBottomLeft - **Type**: `Point?` - **Description**: The margin between the popup and the bottom right corner of the map view after autopanning was performed. ### AutoPanPaddingTopLeft - **Type**: `Point?` - **Description**: The margin between the popup and the top left corner of the map view after autopanning was performed. ### CloseOnEscapeKey - **Type**: `bool` - **Default**: `true` - **Description**: Set it to `false` if you want to override the default behavior of the ESC key for closing of the popup. ### Content - **Type**: `string` - **Description**: The content of the popup. This can be HTML or plain text. ### KeepInView - **Type**: `bool` - **Description**: Set it to `true` if you want to prevent users from panning the popup off of the screen while it is open. ### MaximumHeight - **Type**: `int?` - **Description**: If set, creates a scrollable container of the given height inside a popup if its content exceeds it. ### MaximumWidth - **Type**: `int` - **Default**: `300` - **Description**: Max width of the popup, in pixels. ### MinimumWidth - **Type**: `int` - **Default**: `50` - **Description**: Min width of the popup, in pixels. ### ShowCloseButton - **Type**: `bool` - **Default**: `true` - **Description**: Controls the presence of a close button in the popup. ### PanAnimation - **Type**: `bool` - **Default**: `true` - **Description**: Set it to `false` if you don't want the map to do panning animation to fit the opened popup. ``` -------------------------------- ### MbTilesLayer UrlTemplate Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1MbTilesLayer-members.html Configuration property for the MbTilesLayer URL template. ```APIDOC ## UrlTemplate ### Description Defines the URL template used by the MbTilesLayer to fetch map tiles. ### Context - **Class**: BlazorLeaflet.Models.MbTilesLayer ``` -------------------------------- ### BlazorLeaflet.Models.LatLng Member List Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1LatLng-members.html This section details the members of the LatLng class within the BlazorLeaflet.Models namespace, including inherited members. ```APIDOC ## BlazorLeaflet.Models.LatLng ### Description Represents a geographical coordinate with latitude, longitude, and altitude. ### Members #### Alt - **Alt** (float) - Description of the altitude component. #### Lat - **Lat** (float) - Description of the latitude component. #### Lng - **Lng** (float) - Description of the longitude component. ### Constructors #### LatLng() - **Description**: Default constructor for LatLng. - **Method**: (Implicitly called) #### LatLng(PointF position) - **Description**: Constructs a LatLng object from a PointF. - **Parameters**: - **position** (PointF) - Required - The position to convert. - **Method**: (Implicitly called) #### LatLng(float lat, float lng) - **Description**: Constructs a LatLng object with latitude and longitude. - **Parameters**: - **lat** (float) - Required - The latitude value. - **lng** (float) - Required - The longitude value. - **Method**: (Implicitly called) #### LatLng(float lat, float lng, float alt) - **Description**: Constructs a LatLng object with latitude, longitude, and altitude. - **Parameters**: - **lat** (float) - Required - The latitude value. - **lng** (float) - Required - The longitude value. - **alt** (float) - Required - The altitude value. - **Method**: (Implicitly called) ### Methods #### ToPointF() - **Description**: Converts the LatLng object to a PointF. - **Method**: (Implicitly called) ### Request Example ```json { "lat": 45.50, "lng": -73.58, "alt": 100.0 } ``` ### Response #### Success Response (200) - **LatLng** (object) - Represents a geographical coordinate. - **Alt** (float) - The altitude. - **Lat** (float) - The latitude. - **Lng** (float) - The longitude. #### Response Example ```json { "Alt": 100.0, "Lat": 45.50, "Lng": -73.58 } ``` ``` -------------------------------- ### Layer Properties and Events Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1TileLayer-members.html This section details properties and event handlers related to BlazorLeaflet Layers. ```APIDOC ## Layer Properties and Events ### Description This section details properties and event handlers related to BlazorLeaflet Layers. ### Properties - **Pane** (defined in [BlazorLeaflet.Models.Layer]) - **Popup** (defined in [BlazorLeaflet.Models.Layer]) - **Tooltip** (defined in [BlazorLeaflet.Models.Layer]) ### Event Handlers - **OnTooltipOpen** (defined in [BlazorLeaflet.Models.Layer]) - **PopupEventHandler**(Layer sender, PopupEvent e) (defined in [BlazorLeaflet.Models.Layer]) - **TooltipEventHandler**(Layer sender, TooltipEvent e) (defined in [BlazorLeaflet.Models.Layer]) ``` -------------------------------- ### BlazorLeaflet.Models.Icon Properties Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1Icon.html Overview of the properties available in the Icon model for configuring map markers. ```APIDOC ## Icon Model Properties ### Description The Icon class is used to define the visual representation of markers on a Leaflet map within the BlazorLeaflet component. ### Properties - **Url** (string) - Required - The URL to the icon image (absolute or relative to your script path). - **RetinalUrl** (string) - Optional - The URL to a retina sized version of the icon image. - **Size** (Size?) - Optional - Size of the icon image in pixels. - **Anchor** (Point?) - Optional - The coordinates of the "tip" of the icon (relative to its top left corner). - **PopupAnchor** (Point) - Optional - The coordinates of the point from which popups will "open", relative to the icon anchor. - **TooltipAnchor** (Point) - Optional - The coordinates of the point from which tooltips will "open", relative to the icon anchor. - **ShadowUrl** (string) - Optional - The URL to the icon shadow image. - **ShadowRetinalUrl** (string) - Optional - The URL to a retina sized version of the shadow image. - **ShadowSize** (Size?) - Optional - Size of the shadow image in pixels. - **ShadowAnchor** (Size?) - Optional - The coordinates of the "tip" of the shadow. - **ClassName** (string) - Optional - A custom class name to assign to both icon and shadow images. ``` -------------------------------- ### Event Handlers Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1Polygon-members.html Event handler definitions and properties for layer interactions. ```APIDOC ## Event Handlers ### Description Definitions for event handlers and properties related to layer lifecycle and user interactions. ### Handlers - **OnAdd** - **OnClick** - **OnContextMenu** - **OnDblClick** - **OnMouseDown** - **OnMouseOut** - **OnMouseOver** - **OnMouseUp** - **OnPopupClose** - **OnPopupOpen** - **OnRemove** - **OnTooltipClose** - **OnTooltipOpen** - **PopupEventHandler**(Layer sender, PopupEvent e) ### Properties - **Pane** - **Popup** ``` -------------------------------- ### Create a Polygon Layer Source: https://context7.com/mehigh17/blazorleaflet/llms.txt Defines a filled polygon using an array of coordinate points and custom styling. ```csharp using System.Drawing; using BlazorLeaflet.Models; var polygon = new Polygon { // Define polygon vertices as array of point arrays Shape = new[] { new[] { new PointF(37f, -109.05f), new PointF(41f, -109.03f), new PointF(41f, -102.05f), new PointF(37f, -102.04f) } }, // Stroke styling DrawStroke = true, StrokeColor = Color.Blue, StrokeWidth = 3, StrokeOpacity = 1.0, LineCap = "round", LineJoin = "round", // Fill styling Fill = true, FillColor = Color.LightBlue, FillOpacity = 0.5, // Interactive popup Popup = new Popup { Content = "Colorado State Boundary" } }; polygon.OnClick += (sender, e) => { Console.WriteLine("Polygon clicked!"); }; _map.AddLayer(polygon); ``` -------------------------------- ### Icon Model Properties Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1Icon.html This section describes the properties available for configuring an icon in BlazorLeaflet. ```APIDOC ## Icon Model Properties This section describes the properties available for configuring an icon in BlazorLeaflet. ### PopupAnchor - **Type**: Point - **Default**: Point.Empty - **Description**: The coordinates of the point from which popups will "open", relative to the icon anchor. ### RetinalUrl - **Type**: string - **Description**: The URL to a retina sized version of the icon image (absolute or relative to your script path). Used for Retina screen devices. ### ShadowAnchor - **Type**: Size - **Description**: The coordinates of the "tip" of the shadow (relative to its top left corner) (the same as iconAnchor if not specified). ### ShadowSize - **Type**: Size - **Description**: Size of the shadow image in pixels. ### ShadowUrl - **Type**: string - **Description**: The URL to the icon shadow image. If not specified, no shadow image will be created. ### Size - **Type**: Size - **Description**: Size of the icon image in pixels. ### TooltipAnchor - **Type**: Point - **Default**: Point.Empty - **Description**: The coordinates of the point from which tooltips will "open", relative to the icon anchor. ### Url - **Type**: string - **Required**: Yes - **Description**: The URL to the icon image (absolute or relative to your script path). ``` -------------------------------- ### Add TileLayer to Map Source: https://context7.com/mehigh17/blazorleaflet/llms.txt Configure and add a TileLayer to the map for base map imagery. Supports various tile servers and custom configurations. ```csharp var tileLayer = new TileLayer { UrlTemplate = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", Attribution = "© OpenStreetMap contributors", MinimumZoom = 0, MaximumZoom = 19, Subdomains = new[] { "a", "b", "c" }, DetectRetina = true }; _map.AddLayer(tileLayer); ``` -------------------------------- ### BlazorLeaflet.Models.ImageLayer Members Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1ImageLayer-members.html This section lists all members for the BlazorLeaflet.Models.ImageLayer class, including inherited members. ```APIDOC ## BlazorLeaflet.Models.ImageLayer ### Description Represents an image layer in BlazorLeaflet. ### Members #### Properties - **Alt** (string) - Description not available. - **ClassName** (string) - Description not available. - **Corner1** (PointF) - The first corner of the image layer. - **Corner2** (PointF) - The second corner of the image layer. - **CrossOrigin** (string) - Description not available. - **ErrorOverlayUrl** (string) - Description not available. - **Id** (string) - Description not available. - **IsBubblingMouseEvents** (bool) - Description not available. - **IsInteractive** (bool) - Description not available. #### Methods - **ImageLayer**(string url, PointF corner1, PointF corner2) - Constructor for ImageLayer. - **Layer**() - Constructor for Layer. - **EventHandler**(Layer sender, Event e) - Event handler for layer events. - **MouseEventHandler**(InteractiveLayer sender, MouseEvent e) - Event handler for mouse events on interactive layers. - **NotifyAdd**(Event eventArgs) - Notification for when a layer is added. - **NotifyClick**(MouseEvent eventArgs) - Notification for click events. - **NotifyContextMenu**(MouseEvent eventArgs) - Notification for context menu events. - **NotifyDblClick**(MouseEvent eventArgs) - Notification for double-click events. - **NotifyMouseDown**(MouseEvent eventArgs) - Notification for mouse down events. ``` -------------------------------- ### BlazorLeaflet.Models.Events.ResizeEvent Members Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1Events_1_1ResizeEvent-members.html This section details the members of the ResizeEvent class within the BlazorLeaflet.Models.Events namespace. It includes properties related to the new and old sizes of the map, as well as the event type. ```APIDOC ## BlazorLeaflet.Models.Events.ResizeEvent ### Description Represents an event triggered when the map view's size changes. ### Members - **NewSize** (object) - The new dimensions of the map view. - **OldSize** (object) - The previous dimensions of the map view. - **Type** (string) - The type of the event (inherited from Event). ``` -------------------------------- ### Tooltip Properties Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Models_1_1Tooltip.html Properties specific to the Tooltip class for configuring its behavior and appearance. ```APIDOC ## Tooltip Properties ### Content - **Type**: string - **Description**: The content of the tooltip. - **Access**: get, set ### Direction - **Type**: string - **Default**: "auto" - **Description**: Direction where to open the tooltip. Possible values are: right, left, top, bottom, center, auto. 'auto' will dynamically switch between right and left according to the tooltip position on the map. - **Access**: get, set ### IsPermanent - **Type**: bool - **Description**: Whether to open the tooltip permanently or only on mouseover. - **Access**: get, set ### IsSticky - **Type**: bool - **Description**: If true, the tooltip will follow the mouse instead of being fixed at the feature center. - **Access**: get, set ### Opacity - **Type**: double - **Default**: 0.9 - **Description**: Tooltip container opacity. - **Access**: get, set ``` -------------------------------- ### BlazorLeaflet.Utils.StringHelper.GetRandomString Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/classBlazorLeaflet_1_1Utils_1_1StringHelper-members.html Generates a random string of a specified length using the StringHelper utility class. ```APIDOC ## GetRandomString ### Description Generates a random string of the specified length. ### Parameters #### Method Parameters - **length** (int) - Required - The length of the random string to generate. ``` -------------------------------- ### BlazorLeaflet Map Functions Source: https://github.com/mehigh17/blazorleaflet/blob/master/docs/functions_func.html This section details the core functions available on the BlazorLeaflet Map class for managing map layers and events. ```APIDOC ## AddLayer() ### Description Adds a layer to the map. ### Method Not specified (likely a method call within BlazorLeaflet) ### Endpoint N/A (Class method) ### Parameters None explicitly listed, but implies a layer object is passed. ### Request Example ```csharp map.AddLayer(myLayer); ``` ### Response #### Success Response (200) Returns the updated Map object or void. #### Response Example ```csharp // No explicit return value shown ``` ## GetLayers() ### Description Retrieves all layers currently present on the map. ### Method Not specified (likely a method call within BlazorLeaflet) ### Endpoint N/A (Class method) ### Parameters None. ### Request Example ```csharp var layers = map.GetLayers(); ``` ### Response #### Success Response (200) - **layers** (Array of Layer objects) - A collection of all layers on the map. #### Response Example ```json { "layers": [ // ... layer objects ... ] } ``` ## RaiseOnInitialized() ### Description Raises the OnInitialized event, typically called after the component has been initialized. ### Method Not specified (likely a method call within BlazorLeaflet) ### Endpoint N/A (Class method) ### Parameters None. ### Request Example ```csharp map.RaiseOnInitialized(); ``` ### Response #### Success Response (200) Typically void, as it triggers an event. #### Response Example ```csharp // No explicit return value shown ``` ## RemoveLayer() ### Description Removes a specific layer from the map. ### Method Not specified (likely a method call within BlazorLeaflet) ### Endpoint N/A (Class method) ### Parameters None explicitly listed, but implies a layer object is passed. ### Request Example ```csharp map.RemoveLayer(myLayer); ``` ### Response #### Success Response (200) Returns the updated Map object or void. #### Response Example ```csharp // No explicit return value shown ``` ```