Hi there!
I got a problem with creating mapElements (here Pathelements and Symbolelements tested).
I I add them programmaticly to a new layer, I can't see them on the map, but they are in the elements collection of the layer.
If I add them to a layer, where a shapefile is loaded in (as an example american powerplants as point shapes) then I can see the added Elements, but just if at least one element of the existing power plant points is in the current mapview. For example if i zoom or move to europe, the added mapelements disappear!
Does anyone has any suggestion for this?
I used the following code for adding layer:
Dim kkwLayer As New MapLayer() kkwLayer.LayerName = "kkwLayer" reader = New ShapeFileReader() reader.Uri = "/../../Shapefiles/nuclear-facilities-update" converter = New DataMapping.Converter() reader.DataMapping = TryCast(converter.ConvertFromString("ToolTip=NAME"), DataMapping) kkwLayer.Reader = reader kkwLayer.SymbolType = MapSymbolType.Pentagram theMap.Layers.Add(kkwLayer)
and the following code to add SymbolElements in the mapmouseleftup event:
Dim theMap As XamMap = DirectCast(sender, XamMap) Dim mousePosition As Point = e.Position Dim mapPosition As Point = theMap.Viewport.RootCanvas.RenderTransform.Inverse.Transform(mousePosition) Dim geoPosition As Point = theMap.MapProjection.UnprojectFromMap(mapPosition) Dim latitude As Double = geoPosition.Y Dim longitude As Double = geoPosition.X ' Get Point data using a projection from Geodetic to Cartesian coordinates Dim origin As Point = theMap.MapProjection.ProjectToMap(New Point(longitude, latitude)) 'Dim origin As Point = geoPosition Dim element As New SymbolElement() element.SymbolOrigin = origin element.Caption = "Marker" element.SymbolType = MapSymbolType.Pentagon element.SymbolSize = 15 theMap.Layers("kkwLayer").Elements.Add(element)
The same is happening with PathElements, did not try with SurfaceElements
Thanks a lot in advance!
Edit: I have OpenStreetmaps as Geoimaginery in the background
I found the solution myself. the isAutoWorldRect property has set to be true to the layer.
kind regards