Hi
I want to add multiple layer to the map dynamically. ie i don't know how many layers im going to add at compile time. how can i do this and i want to couple mouse click event to each element. The exact scenario is i have one layer primarily when i zoom in to the primary layer i have to show next layer at one particular zoom level and when i zoom in to the newly added layer i have to add another layer and so on. i can use visiblefromscale property here. i am using Geo spatial data to load map.i have created a service to load shapes but here we will create client to the service in the name of layer and in the GetDateCompleted event we used to import the source. since i don't know the number of layers how can i do this... Can any one help me in this....
ya its working... thanks
You can get notified of the map scale changing by using the WindowRectChanged event. And you can examine the current map zoom level by examining the property WindowZoom. e.g.
private void theMap_WindowRectChanged(object sender, Infragistics.Silverlight.Map.MapWindowRectChangedEventArgs e) { System.Diagnostics.Debug.WriteLine(theMap.WindowZoom.ToString()); }
This help?
-Graham
hi
how to get the zoom level when im zooming in or out. Because i want to display some controls or images over map when i am in particular zoom level. Let say i want to display chart at zoom level 3 and i want to display grid at zoom level five.
Hi David
I am using Geo Spatial data to load map not shape files. I have created service for this. for single layer its working fine. but when i go for more than one layer i.e added dynamically its not working can you please check. My code looks like this
public partial class MainPage : UserControl
{
SqlDbServiceReference.SqlDbServiceClient sqlClient;
string connectionString;
string layerName = "Layer1";
DataMapping.Converter convertor;
public MainPage()
InitializeComponent();
sqlClient = new DEMO_N.SqlDbServiceReference.SqlDbServiceClient();
connectionString = "Integrated Security=True;Initial Catalog=sampledata;Data Source=IE11DT485ZL1S";
convertor = new DataMapping.Converter();
}
private void myMap_Loaded(object sender, RoutedEventArgs e)
sqlClient.GetDataCompleted +=new EventHandler<DEMO_N.SqlDbServiceReference.GetDataCompletedEventArgs>(sqlClient_GetDataCompleted);
sqlClient.GetDataAsync(connectionString, "select * from Plantlevel1");
MessageBox.Show("1");
for (int i = 0; i < 1; i++)
MapLayer newLayer = new MapLayer();
newLayer.VisibleFromScale = i + 1;
newLayer.LayerName = "Layer" + (i + 2);
newLayer.Reader = new SqlShapeReader();
newLayer.DataMapping = (DataMapping)convertor.ConvertFromString("Data=geom;Name=ID");
myMap.Layers.Add(newLayer);
layerName = "Layer2";
SqlDbServiceReference.SqlDbServiceClient newClient1 = new DEMO_N.SqlDbServiceReference.SqlDbServiceClient();
sqlClient.GetDataAsync(connectionString, "select * from plantlevel2");
public void sqlClient_GetDataCompleted(object sender, SqlDbServiceReference.GetDataCompletedEventArgs e)
SqlShapeReader sqlReader = myMap.Layers[layerName].Reader as SqlShapeReader;
if (sqlReader != null)
sqlReader.DataSource = e.Result;
myMap.Layers[layerName].ImportAsync();
you can add a layer to the map in C# using code like this:
MapLayer layer = new MapLayer(); layer.Reader = new ShapeFileReader() { Uri = "usa_st" }; this.xamWebMap1.Layers.Add(layer); layer.ImportAsync();
the mouse clicks can all be handled inside the XamWebMap's ElementClick event handler.