I'm trying to build Silverlight Application that highlights features on the base map when the user clicks on the map. The lat and long value of the clicked position is send to web service,. The web service process the data, creates a new InMemoryFeatureLayer. This InMemoryFeatureLayer is added to the ServerLayerOverlay within the web service.The web service is supposed to send this ServerLayerOverlay to the client so that it is added to the map as a new layer. However, I get an error message as:
"The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error."
My question is:
1) How can I get The ShapeFile Feature layer from the server at the client side. Is it possible at client side to get all the layers from the ServerLayerOverlay that is rendered on the server side?
2) How do I pass the paramerters to the server side to create FleeBooleanStyle dynamically. The sample below uses static value string expression = "(ToInt32(POP_CNTRY)>10000000) AND (ToChar(LANDLOCKED)='Y')". I want to be able to get the users choice to filter the ShapeFileFeatureLayer.
// Native Server 5
// Highlight the countries that are land locked and have a population greater than 10 million
string expression = "(ToInt32(POP_CNTRY)>10000000) AND (ToChar(LANDLOCKED)='Y')";
FleeBooleanStyle landLockedCountryStyle = new FleeBooleanStyle(expression);
// You can access the static methods on these types. We use this
// to access the Convert.Toxxx methods to convert variable types
I have attached my mainpage.xaml,mainPage.xaml.cs, GetGeoDataService.svc, GetGeoDataService.svc.cs and Default.aspx and default.aspx.cs in the attachment . Can someone please point me in the right direction?
There appears to be some misunderstanding regarding the ServerLayerOverlay between the server-side and client-side. They are different objects in our SilverlightEditon product. So you couldn’t send ServerLayerOverlay of server-side to client.
For your first question, we don’t support to get ShapeFileFeatureLayer from the server-side at client-side. However, if you just want to highlight the feature which client clicks; you could do the query operation on the server side and then return the serialized json string to client-side; client-side just need to deserialize this string and put these features into InMemoryFeatureLayer. You could refer the code in the attachment.
For your second question, you just need to use server-side event to implement it.
Another thing is that if you want to run this application please dump cntry02 shape file into App_Data folder.
Please correct me if I misunderstand your meaning.
This just returns the features whose value is exactly equal to the input. I want to return all the features whose value is >= the user input. My target is to display features in map and also display the feature information in the grid.
I was able to display feature information for features whose value was equal to the input in a Datagrid. However I am not able to query features whose value is >input value.
I found the following code
# ShapeFileFeatureLayer worldLayer = new Helper().GetShapeFileLayer("countries02");
# RegexStyle regexStyle = new RegexStyle();
# regexStyle.ColumnName = "CNTRY_NAME";
# regexStyle.RegexItems.Add(new RegexItem(RegularExpressionTextBox.Text, new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.LightGreen))));
I believe the above code is just for styling the feature layer. Is it possible to query all the features that has been highlighted and display their attributes in datagrid.
Yes, you are right. The code posted in your last reply is just for styling the feature layer. We support execute query operation in ShapeFileFeatureLayer. You could refer the code below to implement your requirements:
worldLayer.Open(); DataTable dt = worldLayer.FeatureSource.ExecuteQuery("select * from cntry02 where POP_CNTRY > 100000"); GridView1.DataSource = dt; GridView1.DataBind(); worldLayer.Close();
And then, you need to bind the result of ExecuteQuery operation to a data control.
Is it possible to filter a feature with a wild card. I am using MsSql2008FeatureLayer to create a RoadLayer. How do I create an expression to filter RoadLayer to dispaly only features that have "ave" in the column "FeatureText". The "FeatureText" column is of DataType nvarchar(50).
In SQL SERVER I would use "SELECT ID, FeatureID, MapName,FeatureText FROM RoadsGeometry WHERE FeatureText LIKE '%{0}%'", roadName);
I am trying to create a FleeBooleanStyle by refering to code below:
string expression = "(ToInt32(POP_CNTRY)>10000000) AND (ToChar(LANDLOCKED)='Y')";
FleeBooleanStyle landLockedCountryStyle = new FleeBooleanStyle(expression);
In my code as mentioned below, I am trying to get the value from textbox and build a string to pass into the function GetNameFleeBooleanStyle(string expression).
//Update the map using the new style based on input text
Yes, if you want to filter render features with a wildcard; RegexStyle is the best choice for you. Please refer to the code of server-side below: ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer(MapPath("~/app_data/cntry02.shp")); layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green))); layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
// Draw features based on regular expression RegexStyle regexStyle = new RegexStyle(); regexStyle.ColumnName = "CNTRY_NAME"; regexStyle.RegexItems.Add(new RegexItem(".*land", new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.LightGreen)))); layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(regexStyle);
ServerLayerOverlay regexOverlay = new ServerLayerOverlay("RegexOverlay"); regexOverlay.Layers.Add("RegexLayer", layer);
Sorry, I can't recreate your problem. I have downloaded your files, and what you have done is right. I have used Cntry02 shape file with RegexStyle to test, and it works well. You have posted two images, one is with data and another one is without data. So I think maybe there is something wrong with your code on the client side or server side. If you still have this problem, please provide us with a simple sample to help me to recreate your problem. If your files is big, please send to support@thingeo.com and ask him to forward to me.
My application is working fine now. I am sorry for not posting an update before deleting the thread. I figured out that the problem was with datasize, I changed the data source to a sql table with 1000 records instead of 15,000 records. I was trying to generate a Featurelayer in a map by using spatial data from SQL Server. My application was filterering large chunk of data using RegexStyle and the Server timed out.
Please I am new to silverlight technology I have a sql 2008 spatial layer that i wish to add to Map1 Db credintials: UName: Wael PW:Password DBName: Incidens would you please give me a kick off in how to add this layr to Map1