Hi,
I created 2 layers in a xamMap. One layer displays world map. In other layer, I added the SymbolElements which represents the cities of the countries based on their corresponding longitude and latitude. But all the SymbolElements are displaying at the same location.
The project including the shape file can be downloaded at the following link.
http://cid-fd3332cdd86da8fa.photos.live.com/self.aspx/Public/ShapeFileTest.rar
Please kindly point out if i am missing something.
Your help will be highly appreciated.
Regards,
NNT
Hi NNT,
To be able to load and show the 3 SymbolElements ShapeFileReader's CoordinateSystem needs to be set. Information about the coordinate system and projection can be found in the .prj file. I have not been able to find that file in the rar file you gave.Could you provide it ?
Ivan Kotev
Hi Ivan,
Please find the .prj file at the following link.
http://cid-fd3332cdd86da8fa.photos.live.com/self.aspx/Public/World.rar
Actually i am loading the data from SQL DB. I hope SqlShapeReader's CoordinateSystem can be changed easily.
I really appreciate your help.
Thanks for providing the .prj file. With the information from it I have been able to import the shapefile and add the 3 SymbolElements. Please try the following code snippet:
<ig:XamMap x:Name="MainMap" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsAutoWorldRect="True" MapProjectionType="Miller37" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" WindowZoomMaximum="30" WindowZoomMinimum="0"> <ig:MapNavigationPane x:Name="Navigation" Visibility="Visible" HorizontalAlignment="Right"/> <ig:XamMap.Layers> <ig:MapLayer LayerName="WorldLayer" FillMode="Choropleth" HorizontalContentAlignment="Center" VisibleFromScale="0" HorizontalAlignment="Center" VerticalAlignment="Center" VerticalContentAlignment="Center"> <ig:MapLayer.Reader> <ig:ShapeFileReader Uri="Shapefiles/world2/world"> <ig:ShapeFileReader.CoordinateSystem> <ig:CoordinateSystem UnitType="M" FalseEasting="0.0" FalseNorthing="0.0" > <ig:CoordinateSystem.Projection> <ig:MillerCylindrical EllipsoidType="WGS84" CentralMeridian="10.0" /> </ig:CoordinateSystem.Projection> </ig:CoordinateSystem> </ig:ShapeFileReader.CoordinateSystem> </ig:ShapeFileReader> </ig:MapLayer.Reader> </ig:MapLayer> <ig:MapLayer LayerName="PointLayer"/> </ig:XamMap.Layers></ig:XamMap>
Also I have changed the Laayoune's coordinates from:
citiList.Add(new CitiData { Longitude = -1.32, Latitude = 27.15, CityName = "..." });
to:
citiList.Add(new CitiData { Longitude = -13.2, Latitude = 27.15, CityName = "..." });
The result is:
You are the light of my life.
Thanks so very much.
I'm glad we solved the issue :) Please let me know if you have more questions.
I have one more question. :)
How could I add SymbolElement at the mouse-click location ? I add event handler to xamMap.MapMouseLeftButtonDown event and try to get the position from MapMouseButtonEventArgs.
The problem is the somybol element is displaying at the same location.
Here is my code snippet. I am using the same project which i mentioned before.
void MainMap_MapMouseLeftButtonDown(object sender, MapMouseButtonEventArgs e) { thisLocatorLayer.WorldRect = thisWorldLayer.WorldRect; var pointer = new SymbolElement { SymbolOrigin = e.Position, SymbolType = MapSymbolType.Bubble, SymbolSize = 5, Fill = new SolidColorBrush(Colors.Red), Stroke = new SolidColorBrush(Colors.Purple) }; thisLocatorLayer.Elements.Clear(); thisWorldLayer.Elements.Add(pointer); }
Thanks much for your help.
Please take a look at this forum post: http://community.infragistics.com/forums/p/36373/211645.aspx#211645
Hope that helps.