menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class MapSource - MAUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Class MapSource

    Represents the map source that reads the shape source from the local file, URL, stream or embedded resource.

    Inheritance
    System.Object
    MapSource
    Namespace: Syncfusion.Maui.Maps
    Assembly: Syncfusion.Maui.Maps.dll
    Syntax
    public class MapSource : Object

    Constructors

    MapSource()

    Declaration
    public MapSource()

    Methods

    FromFile(String)

    Returns a new MapSource that reads from file.

    Declaration
    public static MapSource FromFile(string file)
    Parameters
    Type Name Description
    System.String file

    The file.

    Returns
    Type Description
    MapSource

    Returns file map source.

    FromStream(Stream)

    Returns a new MapSource that reads from json stream.

    Declaration
    public static MapSource FromStream(Stream jsonStream)
    Parameters
    Type Name Description
    System.IO.Stream jsonStream

    The json stream.

    Returns
    Type Description
    MapSource

    Returns json stream map source.

    Examples
    • XAML
    • C#
    <map:SfMaps>
       <map:SfMaps.Layer>
          <map:MapShapeLayer x:Name="layer"/>
       </map:SfMaps.Layer>
    </map:SfMaps>
    // Shape path structure should be like SampleName.FolderName.FileName.Extension
    Assembly? assembly = IPlatformApplication.Current?.GetType().GetTypeInfo().Assembly;
    var jsonStream = assembly?.GetManifestResourceStream("MapDemo.ShapeFiles.world_map.json");
    this.layer.ShapesSource = MapSource.FromStream(jsonStream);

    FromStream(Stream, Stream)

    Returns a new MapSource that reads from shapefile stream.

    Declaration
    public static MapSource FromStream(Stream shapeStream, Stream dbfStream)
    Parameters
    Type Name Description
    System.IO.Stream shapeStream

    The shapefile stream.

    System.IO.Stream dbfStream

    The dbf stream.

    Returns
    Type Description
    MapSource

    Returns shape stream map source.

    Examples
    • XAML
    • C#
    <map:SfMaps>
       <map:SfMaps.Layer>
          <map:MapShapeLayer x:Name="layer" />
       </map:SfMaps.Layer>
    </map:SfMaps>
    // Shape path structure should be like SampleName.FolderName.FileName.Extension
    Assembly? assembly = IPlatformApplication.Current?.GetType().GetTypeInfo().Assembly;
    var shapeStream = assembly?.GetManifestResourceStream("MapDemo.ShapeFiles.world_map.shp");
    var dbfStream = assembly?.GetManifestResourceStream("MapDemo.ShapeFiles.world_map.dbf");
    this.layer.ShapesSource = MapSource.FromStream(shapeStream, dbfStream);

    FromUri(Uri)

    Returns a new MapSource that reads from uri.

    Declaration
    public static MapSource FromUri(Uri uri)
    Parameters
    Type Name Description
    System.Uri uri

    The shape source uri.

    Returns
    Type Description
    MapSource

    Returns uri map source.

    Examples
    • XAML
    • C#
    <map:SfMaps>
       <map:SfMaps.Layer>
          <map:MapShapeLayer x:Name="layer" 
                             ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json"/>
       </map:SfMaps.Layer>
    </map:SfMaps>
    SfMaps maps = new SfMaps();
    MapShapeLayer layer = new MapShapeLayer();
    layer.ShapesSource = MapSource.FromUri(new Uri("https://cdn.syncfusion.com/maps/map-data/world-map.json"));
    maps.Layer = layer;
    this.Content = maps;

    Operators

    Implicit(Stream to MapSource)

    Method to implicitly check the stream from the xaml.

    Declaration
    public static implicit operator MapSource(Stream stream)
    Parameters
    Type Name Description
    System.IO.Stream stream

    The stream.

    Returns
    Type
    MapSource

    Implicit(String to MapSource)

    Method to implicitly check the string is Uri or file source from the xaml.

    Declaration
    public static implicit operator MapSource(string source)
    Parameters
    Type Name Description
    System.String source

    The source.

    Returns
    Type
    MapSource

    Implicit(Uri to MapSource)

    Method to implicitly check the string is Uri from the xaml.

    Declaration
    public static implicit operator MapSource(Uri uri)
    Parameters
    Type Name Description
    System.Uri uri

    The uri.

    Returns
    Type
    MapSource
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved