Hello, I'm trying to add a simple simple in a geographical location (lat, lon) using the following code, but nothing appears. Note that the shape file renders correctly on the control. What am I doing wrong?):
<ig:XamMap Grid.Column="2" x:Name="MapMain">
<ig:XamMap.Layers>
<ig:MapLayer x:Name="BasicLayer">
<ig:MapLayer.Reader>
<ig:ShapeFileReader x:Name="BasicShapeReader" Uri="Maps\ShapeFiles\sample"/>
</ig:MapLayer.Reader>
</ig:MapLayer>
</ig:XamMap.Layers>
</ig:XamMap>
Private Sub ShowSymbol()
Dim symbolPoint As Point = MapMain1.MapProjection.ProjectToMap(New Point(23.15, 42.27))
Dim element As New SymbolElement()
element.SymbolOrigin = symbolPoint
element.Caption = "myCaption"
element.SymbolType = MapSymbolType.Bubble
element.SymbolSize = 20
MapMain.Layers(0).Elements.Add(element)
End Sub
Hi,
The coordinates of the symbolPoint are set according to the internal coordinate system of the MapMain1 control, so it is possible that because of differences between the coordinate systems of MapMain1 and MapMain, the point can't be visualized. Do you think this could be the case?
Best regards,Milana Zhileva
No, it is not the case. Here is the complete code for a single control that aims to show a map of europe and a bubble symbol. The map shows correctly, but the symbol does not appear.
Note that I use the europe shape file included in the Infragistics sample demo.
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ig="http://schemas.infragistics.com/xaml" x:Class="ViewMap.MapControl"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<ig:XamMap x:Name="MapMain" IsAutoWorldRect="True">
<ig:MapLayer x:Name="BasicLayer" FillMode="RandomInterpolate">
<ig:ShapeFileReader x:Name="BasicShapeReader" Uri="Maps\InfragisticsDemo\europe"/>
</Grid>
</UserControl>
Imports Infragistics.Controls.Maps
Partial Public Class MapControl
Inherits UserControl
Public Sub New()
InitializeComponent()
Dim symbolPoint As Point = MapMain.MapProjection.ProjectToMap(New Point(23, 39))
element.Caption = "test"
End Class
The SymbolElement doesn't show up because the MapLayers are asynchronously loaded and when you are trying to create the SymbolElement and add it to the map, it is possible that the shape file hasn't been loaded yet. An approach you could use to visualize a symbol on the map when using a shape file is to implement the Imported event of the layer as shown below:
Private Sub BasicLayer_Imported(sender As Object, e As MapLayerImportEventArgs) Dim symbolPoint As Point = MapMain.MapProjection.ProjectToMap(New Point(23, 39))
Dim element As New SymbolElement() element.SymbolOrigin = symbolPoint element.Caption = "myCaption" element.SymbolType = MapSymbolType.Bubble element.SymbolSize = 20
MapMain.Layers(0).Elements.Add(element)End Sub
Hope that helps,Milana Zhileva