|
POST
|
yep just use >=, <, etc.. in the string you set for the Where property. Depending on the underlying data source you can also use between <number> and <number> or between '<date>' and '<date>'. Dates are enclosed in single quote marks like a string. Terry
... View more
04-22-2011
09:19 AM
|
0
|
0
|
551
|
|
POST
|
Jay, Just use a single equal sign in the where clause.
query.Where = "ELEM_TEXT = '" + PrecinctValue2.Trim + "'";
note that are there are single quote marks around precinctvalue2 since this is a string field. Numeric (and date types I believe) do not need these. TG
... View more
04-22-2011
06:55 AM
|
0
|
0
|
551
|
|
POST
|
Thanks again & if anyone is interested, here's what I ended up with -
private void AddResultstoControl(List<IdentifyResult> results, object token)
{
//token contains the map layer index
if (_dataItems == null)
{
_dataItems = new ObservableCollection<DataItem>();
}
if (_dataLinks == null)
{
_dataLinks = new Dictionary<string, List<DataLink>>();
}
if ((results != null) && (results.Count > 0))
{
Graphic feature = null;
string title = string.Empty;
string urlLayer = string.Empty;
string urlFeature = string.Empty;
FeatureLayer flyr = null;
foreach (IdentifyResult result in results)
{
urlFeature = string.Empty;
feature = result.Feature;
title = result.Value.ToString() + " (" + result.LayerName + ")";
urlLayer = MapUtils.GetLayerURL(_Map.Layers[Convert.ToInt32(token.ToString())]) + "/" + result.LayerId;
flyr = new FeatureLayer();
flyr.Url = urlLayer;
//recreating the feature and title otherwise only get the last feature
//see http://blogs.msdn.com/b/ericlippert/archive/2009/11/12/closing-over-the-loop-variable-considered-harmful.aspx
Graphic f2 = feature;
string t2 = title;
flyr.InitializationFailed += FLayer_InitializationFailed;
flyr.Initialized += (s, e) =>
{
string title2 = t2;
Graphic feat = f2;
FeatureLayer fl = s as FeatureLayer;
FeatureLayerInfo fli = fl.LayerInfo;
urlFeature = urlLayer + "/" + feat.Attributes[fli.ObjectIdField];
_dataItems.Add(new DataItem() { Title = title2, Data = feat.Attributes, Id = urlFeature });
_dataLinks.Add(urlFeature, new List<DataLink>());
cbxIdentify.ItemsSource = _dataItems;
if (fli.HasAttachments)
{
fl.QueryAttachmentInfos(feat, FLayer_QryAttachmentsComplete, FLayer_QryAttachmentsFail);
}
};
flyr.Initialize();
}
}
}
void FLayer_InitializationFailed(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine((sender as FeatureLayer).Url + " failed");
}
void FLayer_QryAttachmentsComplete(IEnumerable<AttachmentInfo> AInfos)
{
if (AInfos.Count() < 1)
{
return;
}
string linkId = AInfos.First().Uri.ToString().Replace("/attachments/" + AInfos.First().ID, "");
foreach (AttachmentInfo ai in AInfos)
{
_dataLinks[linkId].Add(new DataLink() { Link = ai.Uri, Caption = ai.Name });
}
}
void FLayer_QryAttachmentsFail(Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
I also changed the _dataItems for a List<DataItem> to ObservableCollection<DataItem> & implemented InfotifyPropertyChange in the DataItem class. I had to do this to get the combobox items to refresh between identifies
... View more
04-21-2011
02:17 PM
|
0
|
0
|
2511
|
|
POST
|
It looks like the API documentation for FeatureLayerInfo is not correct. Initializing a FeatureLayer from a Map Server Layer includes correct values for hasAttachments and ObjectIDField. Can we get the online docs corrected? Thanks again Jennifer, Terry
... View more
04-21-2011
09:03 AM
|
0
|
0
|
2511
|
|
POST
|
I just stopped all the map services used in my application and I do not get any errors. Can you post the code that is throwing the error and in what event handler? I stubbed in a Initialized handler for my dynamic layers and it executes even though the underlying service is not there.
void DynLayer_Initialized(object sender, EventArgs e)
{
ArcGISDynamicMapServiceLayer dlyr = sender as ArcGISDynamicMapServiceLayer;
if (dlyr.Layers == null)
{
return;
}
}
... View more
04-21-2011
06:34 AM
|
0
|
0
|
989
|
|
POST
|
Thanks Jennifer, I'll give it a try. Not sure if it'll help though as the API docs state the FeatureLayerInfo will not return ObejctIDField or HasAttachments for a Map Server, so I'll still have to loop through the attributes to get the OID and hit the REST endpoint to check HasAttachments.
... View more
04-21-2011
06:04 AM
|
0
|
0
|
2511
|
|
POST
|
Would it work for either of you to create a QueryLayer in a MXD and publish that as a Map Service? Here's the doc for a Query Layer in v10 - http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s50000000n000000.htm
... View more
04-19-2011
10:04 AM
|
0
|
0
|
2771
|
|
POST
|
Hi All, Looking through the samples and API docs, the only direct access to a feature's attachments is via FeatureLayer::QueryAttachmentInfos(). Is there, or will there be in v2.2 of the API, a similar method for a MapServer layer? The only way I can see to do it now is through the service's REST end point. The code below is an adaptation of the ESRI Identify sample which uses the REST serive to check for attachments and builds a series of hyperlink buttons to open them if so. I can't really use the AttachmentEditor control for this since it a) requires a FeatureLayer and most of my services do not have this enabled, b) the Identify task returns results from multiple layers, and c) I don't want folks to be able to add or delete attachments. Anyone know of another way to do this? Thanks, Terry
private void IdentifyTask_ExecuteCompleted(Object sender, IdentifyEventArgs args)
{
if (this.Visibility == Visibility.Collapsed)
{
this.Visibility = Visibility.Visible;
}
IdentifyResultsPanel.Visibility = Visibility.Visible;
AddResultstoControl(args.IdentifyResults, args.UserState);
}
private void AddResultstoControl(List<IdentifyResult> results, object token)
{
//token contains the map layer index
if (_dataItems == null)
{
_dataItems = new List<DataItem>();
}
if (_dataLinks == null)
{
_dataLinks = new Dictionary<string, List<DataLink>>();
}
if ((results != null) && (results.Count > 0))
{
Graphic feature = null;
string title = string.Empty;
string oid = string.Empty;
WebClient web = null;
WebClient webAttach = null;
string urlLayer = string.Empty;
string urlFeature = string.Empty;
bool hasOID = false;
foreach (IdentifyResult result in results)
{
web = new WebClient();
webAttach = new WebClient();
urlFeature = string.Empty;
hasOID = false;
feature = result.Feature;
title = result.Value.ToString() + " (" + result.LayerName + ")";
urlLayer = MapUtils.GetLayerURL(_Map.Layers[Convert.ToInt32(token.ToString())]) + "/" + result.LayerId;
foreach (KeyValuePair<string,object> kvp in result.Feature.Attributes)
{
switch (kvp.Key.ToLower())
{
case "objectid":
case "fid":
urlFeature = urlLayer + "/" + kvp.Value.ToString();
_dataItems.Add(new DataItem() { Title = title, Data = feature.Attributes, Id = urlFeature });
_dataLinks.Add(urlFeature, new List<DataLink>() );
cbxIdentify.Items.Add(title);
urlFeature += "/attachments?f=json";
hasOID = true;
break;
default:
break;
}
if (hasOID)
{
break;
}
}
//see if layer hasAttachements; download them if so
web.DownloadStringCompleted += (s, e) =>
{
bool hasAttachments = false;
JsonObject jsObj = (JsonObject)JsonObject.Parse(e.Result);
if (jsObj.ContainsKey("hasAttachments"))
{
hasAttachments = Convert.ToBoolean(jsObj["hasAttachments"].ToString());
}
else
{
hasAttachments = false;
}
if (hasAttachments)
{
webAttach = new WebClient();
webAttach.DownloadStringCompleted += web_DownloadStringCompleted;
webAttach.DownloadStringAsync(new Uri(urlFeature), urlFeature);
}
};
web.DownloadStringAsync(new Uri(urlLayer + "?f=json"));
}
cbxIdentify.UpdateLayout();
//cbxIdentify.SelectedIndex = 0;
}
}
void web_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
//e will have the JSON of a features attachments
string urlbase = e.UserState.ToString().Replace("/attachments?f=json", "");
DataLink dl = null;
JsonObject jsObj = (JsonObject)JsonObject.Parse(e.Result);
if (jsObj.ContainsKey("error"))
{
return;
}
JsonArray AttachInfos = (JsonArray)jsObj["attachmentInfos"];
foreach (JsonObject jOb in AttachInfos)
{
dl = new DataLink() { Caption = jOb["name"].ToString().Trim('"'), Link = new Uri(urlbase + "/attachments/" + jOb["id"].ToString()) };
_dataLinks[urlbase].Add(dl);
}
}
//class for data grid binding
private class DataItem
{
private string _id;
private string _Title;
private IDictionary<string, Object> _Data;
public string Id
{
get { return _id; }
set {_id = value;}
}
public string Title
{
get { return _Title; }
set { _Title = value; }
}
public IDictionary<string, Object> Data
{
get { return _Data; }
set { _Data = value; }
}
}
//for storing links to attachments
private class DataLink
{
private Uri _link;
private string _caption;
public Uri Link
{
get { return _link; }
set { _link = value; }
}
public string Caption
{
get { return _caption; }
set { _caption = value;}
}
}
... View more
04-19-2011
09:54 AM
|
0
|
16
|
5621
|
|
POST
|
Add a handler for the InitializationFailed event on each layer in your map. XAML
<esri:Map x:Name="MyMap" >
<esri:ArcGISDynamicMapServiceLayer ID="MyLayer"
Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"
InitializationFailed="DynLayer_InitializationFailed"/>
</esri:Map>
C# void DynLayer_InitializationFailed(object sender, EventArgs e)
{
Layer lyr = sender as Layer;
MyMap.Layers.Remove(lyr);
} I know this does not really answer the question as to checking if the service is running or not but should prevent the error and will remove the broken layer from the map.
... View more
04-18-2011
08:15 AM
|
0
|
0
|
989
|
|
POST
|
Did you set the binding of the Map.TimeExtent to the TimeSlider.Value? Nope, completely forgot about that part.:o I created another binding in the code behind like this & it works great.
Binding b = new Binding("Value");
b.Source = timeControl;
_Map.SetBinding(Map.TimeExtentProperty, b);
Thanks Chris! TG
... View more
04-06-2011
10:48 AM
|
0
|
2
|
715
|
|
POST
|
I've created a user control which contains a combobox populated w/ the names of the layers in my map and a time slider. When the user selects a layer in the combobox, it checks to see if the selected layer is a dynamic layer with a valid timeextent. If so, I try to set the timeslider's min, max and value properties using that layer via bindings. This seems to work (in debug timeControl has valid properties at the end of cbxLayers_SelectionChanged) but when the user changes the date range in the slider, the data on the map do not change to reflect that time period. One thing to note is that the layers in the map are all added when the maps loads, controlled by a parameter passed in. This means I cannot set the binding in the XAML as the map may not contain any layers which support or have a TimeExtent. Anyone see what I'm missing? Thanks, TG XAML
<esri:TimeSlider x:Name="timeControl" Grid.Row="1" TimeMode="TimeExtent"
PlaySpeed="0:0:1.5" Height="20" Width="200"/>
CS
private void cbxLayers_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ArcGISDynamicMapServiceLayer dlyr = null;
ComboBoxItem cbi = ((sender as ComboBox).SelectedValue as ComboBoxItem);
foreach (Layer l in _Map.Layers)
{
if (l.ID.ToLower() == cbi.Content.ToString().ToLower())
{
if (l is ArcGISDynamicMapServiceLayer) // need to add other time enabled layers later..
{
dlyr = l as ArcGISDynamicMapServiceLayer;
}
break;
}
}
// time slider is in a tab control, on a tab called tabTime - hide if layer does not support Time Extent
TabItem tab = tabQueryType.FindName("tabTime") as TabItem;
if (dlyr == null)
{
tab.Visibility = Visibility.Collapsed;
}
else if (dlyr.TimeExtent == null)
{
tab.Visibility = Visibility.Collapsed;
}
else
{
tab.Visibility = Visibility.Visible;
Binding b = new Binding("Layers[" + dlyr.ID + "].TimeExtent.Start");
b.Source = _Map;
b.Mode = BindingMode.OneWay;
timeControl.SetBinding(TimeSlider.MinimumValueProperty, b);
b = new Binding("Layers[" + dlyr.ID + "].TimeExtent.End");
b.Source = _Map;
b.Mode = BindingMode.OneWay;
timeControl.SetBinding(TimeSlider.MaximumValueProperty, b);
b = new Binding("Layers[" + dlyr.ID + "].TimeExtent");
b.Source = _Map;
b.Mode = BindingMode.OneWay;
timeControl.SetBinding(TimeSlider.ValueProperty, b);
List<DateTime> times = new List<DateTime>();
DateTime dt = dlyr.TimeExtent.Start;
while (dt < dlyr.TimeExtent.End)
{
times.Add(dt);
dt = dt.AddDays(7);
}
timeControl.Intervals = times;
}
tabQueryType.SelectedIndex = 0;
}
... View more
04-06-2011
07:23 AM
|
0
|
4
|
4670
|
|
POST
|
Create a Geometry Service on your ArcGIS Server and use it's ProjectAsych method. Here's a link to the ESRI sample - http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Project
... View more
04-06-2011
06:41 AM
|
0
|
0
|
621
|
|
POST
|
I didn't think so, but wanted to see if there was anything undocumented. I think I'll just try opening AGX and copying the address info to the user's clipboard so they can paste it into the Find tool to reduce data entry errors. Thanks for the reply, Terry
... View more
01-31-2011
08:18 AM
|
0
|
0
|
394
|
|
POST
|
Is there a way to open AGX and pass in parameters to a tool? What I'd like to do is add a button to another application I have that opens AGX and passes an address to the Find tool, so the user can see the location on a map & find the lat longs for recording in a data form. Thanks! Terry
... View more
01-26-2011
01:06 PM
|
0
|
2
|
751
|
|
POST
|
Thanks for the link Mike. I had looked at the Table::Search method but it looks to work more like a spatial filter than performing an intersect. I think we've decided to move the project in question to an Engine application given we're looking at writing a lot of non AGX code any way. Thanks again, TG
... View more
11-23-2010
04:57 AM
|
0
|
0
|
380
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-23-2017 08:59 AM | |
| 1 | 06-15-2016 03:27 PM | |
| 1 | 01-14-2016 09:55 AM | |
| 2 | 12-14-2012 09:38 AM | |
| 2 | 10-23-2017 01:22 PM |
| Online Status |
Offline
|
| Date Last Visited |
07-17-2024
08:14 PM
|