SfMaps inside of SfDialog

Trying to create a movable window with a map inside of it. I found an example of a SfMap inside of a SfDashboardLayout, but i would prefer for the Dialog box functionality to display my map. 

This is my code:

<SfDialog ID="MapDialogue" Width="53%" Height="62%" IsModal="false" AllowDragging="true" EnableResize="true" ShowCloseIcon="true">
   <DialogTemplates>
      <Header>My Map</Header>
      <Content>
         <SfMaps>
            <MapsTitleSettings Text="My Map"></MapsTitleSettings>
            <MapsZoomSettings Enable="true"></MapsZoomSettings>
            <MapsLayers>
               <MapsLayer Visible="true" ShapdeData='new {dataOptions="https://cdn:syncfusion.com/maps/map-data/world-map.json"}' TValue="string">
               </MapsLayer>
          </SfMaps>
       </Content>
   </DialogTemplates>
</SfDialog>


I am just using the world map from the documentation. I have found the map when inspecting the html under Content but it seems to be invisible to user except for the zoom in and out plus reset zoom buttons.

1 Reply

VJ Vinitha Jeyakumar Syncfusion Team December 23, 2021 07:42 AM UTC

Hi Dylan, 
 
 
Greetings from Syncfusion support, 
 
 
Your reported issue can be resolved by calling the refresh method of Maps control in the dialog Opened event. Please check the code below, 
 
Code snippet: 
<SfDialog ID="MapDialogue" @bind-Visible="@IsVisible" Width="53%" Height="62%" IsModal="false" AllowDragging="true" EnableResize="true" ShowCloseIcon="true"> 
    <DialogEvents Opened="@onOpen"></DialogEvents> 
    <DialogTemplates> 
        <Header>My Map</Header> 
        <Content> 
             
            <SfMaps @ref="map"> 
                <MapsTitleSettings Text="My Map"></MapsTitleSettings> 
                <MapsZoomSettings Enable="true"></MapsZoomSettings> 
                <MapsLayers> 
                    <MapsLayer ShapeData='new {dataOptions= https://cdn.syncfusion.com/maps/map-data/world-map.json}' TValue="string"> 
                    </MapsLayer> 
                </MapsLayers> 
            </SfMaps> 
        </Content> 
    </DialogTemplates> 
</SfDialog> 
 
@code { 
    SfMaps map; 
    private bool IsVisible { get; set; } = true; 
 
    private void OpenDialog() 
    { 
        this.IsVisible = true; 
         
    } 
    public void onOpen() 
        { 
            map.Refresh(); 
        } 
 
} 
 
 
Regards, 
Vinitha 


Loader.
Up arrow icon