For this map component in SyncFusion, is it possible to show the view just for Canada and just for the U.S.? Is it possible to zoom into the U.S. and hover over the state to get more details in hover text, and zoom back out to the U.S. view afterwards? Is it possible to do that for Canadian provinces too? And is it possible to focus on North America (minus Greenland) instead of the whole world?
Thank you.
|
<SfMaps ID="Maps" @ref="MapsRef" BaseLayerIndex="@LayerIndex">
<MapsEvents ShapeSelected="ShapeSelection" />
<MapsLayers>
<MapsLayer ShapeData='new {dataOptions= "north-america.json"}'>
<MapsLayerTooltipSettings Visible="true" ValuePath="name"></MapsLayerTooltipSettings>
</MapsLayer>
<MapsLayer ShapeData='new {dataOptions ="usa.json"}' TValue="string">
<MapsLayerTooltipSettings Visible="true" ValuePath="name" />
</MapsLayer>
<MapsLayer ShapeData='new {dataOptions ="canada.json"}' TValue="string">
<MapsLayerTooltipSettings Visible="true" ValuePath="name" />
</MapsLayer>
</MapsLayers>
</SfMaps>
@code{
private void ShapeSelection(ShapeSelectedEventArgs args)
{
Dictionary<string, string> DrillData = args.Data;
if (MapsRef.BaseLayerIndex == 0)
{
if (DrillData["name"] == "United States")
{
LayerIndex = 1;
this.StateHasChanged();
}
else if (DrillData["name"] == "Canada")
{
LayerIndex = 2;
this.StateHasChanged();
}
//..
//..
}
}
} |
Hi Indumathi,
Thank you for the reply. It looks like it is possible to hover over U.S. states and Canadian provinces to get more information. Is it possible to display custom information in the tooltip, beyond state details?
Also, is it possible to view the U.S. and Canada, without Greenland?
Thank you,
Signe
|
Queries |
Details | |
|
Is it possible to display custom information in the tooltip, beyond state details? |
We can achieve your requirement of displaying the custom information in the toolitp using the "TooltipTemplate" property in the "MapsLayerTooltipSettings". The value of the field name from the data source can be displayed in the tooltip. The "shapeDataPath" and "shapePropertyPath" properties are used to connect the data source with the shape data of the Maps. The "shapeDataPath" property takes the field name from the data source as value whereas “shapePropertyPath” property takes the field name from the shape data of the map as value. When the values of both these properties match, the value can be displayed in the tooltip. Please find the code snippet for the same below.
We have created a sample and screen shot to demonstrate the same and it can be downloaded from the below link.
Screenshot –
Please let us know that the above sample meets your requirement.
| |
|
Also, is it possible to view the U.S. and Canada, without Greenland? |
We gave the sample with the United States and Canada without Greenland in the prior response. Maps control is intended to display the JSON files with GeoJSON data. We do not handle the creation and updating of the GeoJSON data of the maps. However, we have found a GeoJSON map of U.S. and Canada without Greenland while searching online only.
NOTE: If you need to modify the GeoJSON map, please check with any online map vendors for the shapes. |