Hi.
I want to display some shape files using silverlight. I wanted to use xamMap or xamWebMap. btw. what is the difference between those two? I coulnd find xamWebMap control anywhere in the toolbox (i'm using trial version if that helps) but I did found xamMap so I tried with that. Where can I find some instructions on how to start? I found gazzillion examples for xamWebMap but none for xamMap. For the beggining I want to just load simple shp file from the local disc. And also what do I have to do to use xamWebMap?
Hi grabah,
Setting EllipsoidType="WGS84" fixed the issue. SphericalMercator's EllipsoidType sets or gets the current projections's datum.
For the zooming issue try setting XamMap's WindowRect and WorldRect explicitly after shapefile is imported:
MapLayer layer = new MapLayer();
ShapeFileReader reader = new ShapeFileReader();
CoordinateSystem cord = new CoordinateSystem();SphericalMercator spMerc = new SphericalMercator();spMerc.EllipsoidType = EllipsoidType.WGS84;cord.Projection = spMerc;reader.CoordinateSystem = cord;
reader.Uri = "akcijski_koridor";DataMapping.Converter converter = new DataMapping.Converter();reader.DataMapping = converter.ConvertFromString("Caption=POLGON") as DataMapping;layer.Reader = reader;xamMap1.Layers.Add(layer);
layer.Imported += (layerSender, layerEvents) =>{ if (layerEvents.Action == MapLayerImportAction.End) { xamMap1.WindowRect = xamMap1.WorldRect = layer.WorldRect; }};
layer.ImportAsync();
Could you please check again if latest SR is applied. As a workaround try to remove it with the following code:
xamMap.Layers.RemoveAt(0);
Regards,
Ivan Kotev
It finally works, great! thank you very much!
so whats was the catch, EllipsoidType="WGS84"?
Im doing the loading from the code like this:
MapLayer layer = new MapLayer(); ShapeFileReader reader = new ShapeFileReader(); CoordinateSystem cord = new CoordinateSystem(); SphericalMercator spMerc = new SphericalMercator(); spMerc.EllipsoidType = EllipsoidType.WGS84; cord.Projection = spMerc; reader.CoordinateSystem = cord; reader.Uri = "akcijski_koridor"; DataMapping.Converter converter = new DataMapping.Converter(); reader.DataMapping = converter.ConvertFromString("Caption=POLGON") as DataMapping; layer.Reader = reader; xamMap1.Layers.Add(layer); layer.ImportAsync();
I still have some problems with zooming thou. When first loaded shape file is mostly centered corectly, but if I trie to replace it with some other shape in a new layer I can't get it to display properly. I guess it's becouse of the funky coordinates and world sizes in those files...
and also I updated to latest version but still problem with persisted image after all layers are clerad is here. Only after I move new layer or zoom it new shape shows up and old one dissapears.
Try the following XAML code:
<ig:XamMap> <ig:XamMap.Layers> <ig:MapLayer> <ig:MapLayer.Reader> <ig:ShapeFileReader Uri="Shapefiles/akcijski_koridor"> <ig:ShapeFileReader.CoordinateSystem> <ig:CoordinateSystem> <ig:CoordinateSystem.Projection> <ig:SphericalMercator EllipsoidType="WGS84" /> </ig:CoordinateSystem.Projection> </ig:CoordinateSystem> </ig:ShapeFileReader.CoordinateSystem>
</ig:ShapeFileReader> </ig:MapLayer.Reader> </ig:MapLayer> </ig:XamMap.Layers></ig:XamMap>
The result is:
If you want map elements to have the same Fill color you can set MapLayer's Fill property:
Fill="DodgerBlue" and FillMode="None"
it should look like this:
Yes, You can send the shapefiles and we will investigate the issue further.
Thanks,