POST
|
The geometry is polygonal, so I shouldn't have to expand to an envelope, and I am only selecting one at a time. I got the problem to throw an exception. According to my script log, it says Message: System.InvalidCastException: Unable to cast object of type 'ESRI.ArcGIS.Client.Toolkit.DataSource.TempTypeMinus258081229' to type 'ESRI.ArcGIS.Client.Graphic'. [ATTACH=CONFIG]16120[/ATTACH] Any ideas? Current Code is attached:
private void RunWestTexasCountyQuery()
{
ClearAllGraphics();
GraphicsLayer searchGraphicsLayer = TabletMap.Layers["SearchGraphicsLayer"] as GraphicsLayer;
ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query()
{
ReturnGeometry = true,
OutSpatialReference = TabletMap.SpatialReference,
Where = "CNAME IN ('CULBERSON', 'JEFF DAVIS', 'LOVING', 'REEVES', 'WARD', 'WINKLER')"
};
query.OutFields.Add("CNAME");
QueryTask queryTask = new QueryTask("<serviceURL>");
queryTask.ExecuteCompleted += (s, a) =>
{
foreach (Graphic g in a.FeatureSet.Features)
searchGraphicsLayer.Graphics.Add(g);
};
queryTask.ExecuteAsync(query);
queryTask.Failed += QueryTask_Failed;
}
private void QueryTask_Failed(object sender, TaskFailedEventArgs args)
{
MessageBox.Show("Query execute error: " + args.Error);
}
private void BookmarksDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
foreach (ESRI.ArcGIS.Client.Graphic g in e.AddedItems)
{
g.Select();
TabletMap.ZoomTo(g.Geometry);
}
foreach (ESRI.ArcGIS.Client.Graphic g in e.RemovedItems)
g.UnSelect();
}
... View more
07-16-2012
06:47 AM
|
0
|
0
|
373
|
POST
|
Hello, I am following this sample to create legend. My requirement is to remove the layer from the legend when it is turned off due to scale dependant visibility and add it back to the legend when it is turned on.This layer could be feature layer or any sub layer from the map service.I guess, I have to call Legend::Refresh in the Map's extent changed event. However,I am not being able to figure-out how to do this.To be frank,I am having hard time to understand the LayerItemViewModel class. So can anybody help me on this issue?I would appreciate it. I have attached screen shot of my Legend control with map. Thanks. It's easier than you'd think. Just change ShowOnlyVisibleLayers from "False" to "True" from the sample. <esri:Legend Map="{Binding ElementName=MyMap}"
LayerIDs="Points of Interest, United States"
LayerItemsMode="Tree"
ShowOnlyVisibleLayers="True"
Refreshed="Legend_Refreshed">
... View more
07-16-2012
05:03 AM
|
0
|
0
|
486
|
POST
|
Solved It was a problem with the URL as you had suggested. Code works perfectly now that I specified the port. For some reason my server has decided to only return query results sometimes if the port isn't specified. But that's a fix for another day. Now, zoomto isn't working properly. I'm using this for an autozoom
private void CountiesDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
foreach (Graphic g in e.AddedItems)
{
g.Select();
TabletMap.ZoomTo(g.Geometry);
}
foreach (Graphic g in e.RemovedItems)
g.UnSelect();
}
However, whenever my app runs the query, the screen goes blank white. No crash, no debug throwback, not decernable issues seen in fiddler. Just blank screen. Is my code correct here or does it need to be changed?
... View more
07-13-2012
01:10 PM
|
0
|
0
|
373
|
POST
|
That's exactly what I had done to work around that problem. Thanks again for all the help on this, works like a dream now. On a side note, and I know this is probably an extremely basic question (though I can't find a direct answer anywhere), but that's the problem with teaching yourself a programming language is the basics get passed over. But how would I go about changing the layerID integer to an array so multiple layers can be toggled by one command instead of writing a single command for each layer toggled. I.E. something like private void ToggleVisibility(int[] layerIds)
{
var westTexas = MyMap.Layers["West Texas"] as ArcGISDynamicMapServiceLayer;
if (westTexas == null) return;
bool isVisible = westTexas.VisibleLayers.Contains(layerIds);
westTexas.SetLayerVisibility(layerId, !isVisible);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
ToggleVisibility(0, 1 ,2, 3);
} instead of private void ToggleVisibility(int layerId)
{
var westTexas = MyMap.Layers["West Texas"] as ArcGISDynamicMapServiceLayer;
if (westTexas == null) return;
bool isVisible = westTexas.VisibleLayers.Contains(layerId);
westTexas.SetLayerVisibility(layerId, !isVisible);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
ToggleVisibility(0);
ToggleVisibility(1);
ToggleVisibility(2);
ToggleVisibility(3);
ToggleVisibility(4);
ToggleVisibility(8);
}
... View more
07-13-2012
08:25 AM
|
0
|
0
|
122
|
POST
|
The path should be C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\Silverlight\v5.0\Libraries, or something very close to that on your system. Good luck.
... View more
07-12-2012
07:06 AM
|
0
|
0
|
186
|
POST
|
http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#EditorTracking This should be exaclty what you need. To set up the secure services on your server, add the roles and users first here. http://resources.arcgis.com/en/help/main/10.1/index.html#/Managing_users_in_Manager/0154000005ps000000/ Then set permissions.
... View more
07-12-2012
07:04 AM
|
0
|
0
|
163
|
POST
|
Url is definitely fine. I had run this code Where = string.Format("CNAME LIKE '%{0}%'", FindText.Text), instead of the sql string you helped with, accompanied with a FindText box and it returns reuslts. The erro message has given something interesting though. [ATTACH=CONFIG]16003[/ATTACH] For some reason I'm getting a security exception. Any clues as to how to fix this?
... View more
07-12-2012
05:00 AM
|
0
|
0
|
373
|
POST
|
It works when I query CNAME = 'CULBERSON' through the query page in the services browser under the Where search textbox,as well as, CNAME IN ('CULBERSON', 'JEFF DAVIS', 'LOVING', 'REEVES', 'WARD', 'WINKLER') . However, when I input it into my applications code as Where = "CNAME IN ('CULBERSON', 'JEFF DAVIS', 'LOVING', 'REEVES', 'WARD', 'WINKLER')" , no results are given. I believe it might be a problem on the way we write it on the apps side. I'll keep tinkering with it, but if you think of anything please let me know. However, the problem could lie with the execution of another part of the query code, though I don't see it. This does not work either. private void RunCountyQuery()
{
ClearAllGraphics();
GraphicsLayer searchGraphicsLayer = TabletMap.Layers["SearchGraphicsLayer"] as GraphicsLayer;
int[] ObjIDs = new int[6]{55,122,151,195,238,248};
ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query()
{
ReturnGeometry = true,
OutSpatialReference = TabletMap.SpatialReference,
ObjectIDs = ObjIDs,
};
query.OutFields.Add("CNAME");
QueryTask queryTask = new QueryTask("<serverURL>");
queryTask.ExecuteCompleted += (s, a) =>
{
foreach (Graphic g in a.FeatureSet.Features)
searchGraphicsLayer.Graphics.Add(g);
};
queryTask.ExecuteAsync(query);
}
... View more
07-11-2012
10:46 AM
|
0
|
0
|
508
|
POST
|
See if this works
Where = "CNAME IN ('CULBERSON', 'JEFF DAVIS', 'LOVING', 'REEVES', 'WARD', 'WINKLER')"
Still nothing, I also tried
Where = string.Format("CNAME IN ('CULBERSON','JEFF DAVIS','REEVES','WARD','WINKLER')"),
In case it had to be wrapped in a Format like the example in the samples.
... View more
07-11-2012
08:36 AM
|
0
|
0
|
508
|
POST
|
Also, I still seem to be having trouble with my query working properly. Do you mind taking a look at my code and telling me what I've done wrong? As stated earlier, my desired result is a list of these six counties showing up in the FeatureDataGrid, yet for some reason, it isn't returning any results. In the datatables, the column name is CNAME and the six counties I want to display are listed in the Where SQL IN clause below.
private void RunCountyQuery()
{
ClearAllGraphics();
GraphicsLayer searchGraphicsLayer = TabletMap.Layers["SearchGraphicsLayer"] as GraphicsLayer;
ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query()
{
ReturnGeometry = true,
OutSpatialReference = TabletMap.SpatialReference,
Where = "CNAME IN (CULBERSON, JEFF DAVIS, LOVING, REEVES, WARD, WINKLER)"
};
query.OutFields.Add("CNAME");
QueryTask queryTask = new QueryTask("<mapserviceURL>");
queryTask.ExecuteCompleted += (s, a) =>
{
foreach (Graphic g in a.FeatureSet.Features)
searchGraphicsLayer.Graphics.Add(g);
};
queryTask.ExecuteAsync(query);
} Also, do you know how to make the resulting featureset to only be sent to one featuredatagrid, instead of all of them?
... View more
07-11-2012
07:04 AM
|
0
|
0
|
508
|
POST
|
The FeatureDataGrid binds to a GraphicsLayer so there are two approaches you can use. Either using a FeatureLayer (which inherits from GraphicsLayer) or use a GraphicsLayer and add the Graphics objects in code. Personally I think if possible the FeatureLayer simplifies things over running a Query and then adding Graphics to the GraphicsLayer, but neither way is more correct than the other. As for using ObjectId property or the Where clause it is really another case of there is no best answer. I think in general the Where is more standard because the ObjectID could potentially change (like if for some reason data was reloaded into a Feature Class). If there is not some attribute that is being used (e.g., all counties with population over 1,000,000 or counties with the best BBQ 🙂 - you are in TX right?) you can always use a SQL In clause on the name (Where = "Name In (CountyA, CountyB,...)") This thread may help with how to go about zooming to the location when the user clicks on the item in the FeatureDataGrid. http://forums.arcgis.com/threads/58076-zoom-to-points?p=201782#post201782 Hope that helps Thanks for the answer Joe. You've been helpful as always. As for the zoomto questions, the new featuredatagrid, which I've chosen to use because the featurelayer simplifies things for me, has a toggle in the options to automatically zoom to any point selected (http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#OrderByFieldQuery), but if I add the zoomto code manually (like we had to before the featuredatagrid was in the toolkit), it makes the code wonky and sometimes throws exceptions. I was hoping to see if anyone that had worked directly on the new toolkit could tell me if the option to have it zoomto automatically could be set as the default or not. I've checked through the API reference library and can find absolutely no reference to it, so my inclination is no without modifying the source code, but I just wanted to see. Thanks again though Joe.
... View more
07-11-2012
05:00 AM
|
0
|
0
|
508
|
POST
|
Hi, I'm trying to make a datagrid that autopopulates with a handful of counties. I believe the new featuredatagrid and the querytask would be the best way to do this so I can keep the parameters dynamic as to which counties are in the datagrid. I have two questions about this, how would I go about only returning specific, pre-set results through the querytask (is it through use of the "Where" public property or "ObjectID")? And my second question is, how would I pre-set the featuredatagrid to autozoom to selected Item instead of autozoom to selected being toggle off by default. I can't seem to find that property setter anywhere in the API reference. Thanks for any help.
... View more
07-10-2012
07:26 AM
|
0
|
16
|
1116
|
POST
|
Solved, using a variation of my original method. For some reason the way it was written required the togglelayer action to be attempted twice before the first time it was successful, the way i have it written now has more control and works out of the gate. It's not as elegant as your code Joe, but it works for me. Thank you for the help!
private void toggleSubLayerON(int sublayerId)
{
ArcGISDynamicMapServiceLayer layer= TabletMap.Layers["Layer"] as ArcGISDynamicMapServiceLayer;
List<int> visibleLayerList =
layer.VisibleLayers != null
? layer.VisibleLayers.ToList() : new List<int>();
visibleLayerList.Add(sublayerId);
layer.VisibleLayers = visibleLayerList.ToArray();
}
private void toggleSubLayerOFF(int sublayerID)
{
ArcGISDynamicMapServiceLayer layer= TabletMap.Layers["Layer"] as ArcGISDynamicMapServiceLayer;
List<int> visibleLayerList =
layer.VisibleLayers != null
? layer.VisibleLayers.ToList() : new List<int>();
visibleLayerList.Remove(sublayerID);
layer.VisibleLayers = visibleLayerList.ToArray();
}
... View more
07-09-2012
11:36 AM
|
0
|
0
|
516
|
POST
|
Thanks Joe, I didn't realize this was working because of a strange problem with the my app. The sublayerToggle you provided is being used as an action strung into a button click , but the app also has a Legend with checkboxes controlling the sublayer visibility in my app, when I toggle the layer on or off on the legend first, then the sublayerToggle also works with the button click, but if it hasn't been toggled with the legend, the toggle strung to the button click doesn't do anything. I'm very confused as to why it's doing this, but I'm also pretty sure it has nothing to do with the code you provided me at this point. Thank you very much for the help. Nevermind. I recreated a small silverlight app with the dynamicmaplayer and a button, strung to the ToggleVisibility action, which was uneffective in toggling the visibility. However, when I added a templated legend with checkbox toggle for the sublayers (from http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#LegendWithTemplates), the button toggle with work after it's been turned on or off with the legend first. Do you know what could be causing this problem? The Code for the App is
private void ToggleVisibility(int layerId)
{
var westTexas = MyMap.Layers["West Texas"] as ArcGISDynamicMapServiceLayer;
if (westTexas == null) return;
bool isVisible = westTexas.VisibleLayers.Contains(layerId);
westTexas.SetLayerVisibility(layerId, !isVisible);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
ToggleVisibility(0);
}
And i did get it to throw an exception once. [ATTACH=CONFIG]15869[/ATTACH]
... View more
07-09-2012
08:02 AM
|
0
|
0
|
516
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|