|
POST
|
I am trying to restrict an add-in from working on the basemap layer and the top layer in the TOC. The add-in shows in the right click menu of a layer. The code I have disables the add-in correctly if you left click the layer to select and then right click to get the context menu. However, if you right click another layer to select and open the right click menu at the same time it is not working correctly. It still at the previously selected layer to see if the add-in can execute. If I right click the layer again it works fine. It seems like the right click menu is appearing before the canexecute event finishes. Is it something I am doing wrong in my code?
namespace LayerOrder.AddIns
{
[Export(typeof(ICommand))]
[DisplayName("Move Layer Up")]
[ESRI.ArcGIS.Client.Extensibility.Description("Move selected layer up.")]
public class MoveLayerUp : ICommand
{
#region ICommand members
public bool CanExecute(object parameter)
{
Layer myselectedlayer = MapApplication.Current.SelectedLayer;
int mylayerid = MapApplication.Current.Map.Layers.IndexOf(myselectedlayer);
int layercount = MapApplication.Current.Map.Layers.Count;
if (mylayerid == 0)
return false;
else if (mylayerid == (layercount - 1))
return false;
else
return true;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
Layer selectedlayer = MapApplication.Current.SelectedLayer;
int layerid = MapApplication.Current.Map.Layers.IndexOf(selectedlayer);
MapApplication.Current.Map.MoveLayer(layerid, layerid + 1);
}
#endregion
}
}
... View more
06-20-2012
08:16 AM
|
0
|
1
|
2799
|
|
POST
|
Has this bug been squished in the 10.1 production release? Thanks.
... View more
06-14-2012
04:47 AM
|
0
|
0
|
1456
|
|
POST
|
This can be found on ArcGIS.com here and is also available in the Viewer's code gallery. This is a production quality, ready-to-use tool with full source code included. The new Measuring Add-in works great. Thanks for putting this out. It will be very beneficial for a lot of people. One thing I noticed is that you have to run a tool before specifying your units of measurement. It would be nice to have that option before measuring. If I decide to use your tool I will change myself but others that do not have the knowledge how to due that may benefit from a future update to the tool to allow this.
... View more
05-24-2012
08:20 AM
|
0
|
0
|
1235
|
|
POST
|
Update: I tied the GetResultDataAsync to the onclick event of a button and specified the jobID of a know job that has results in the server jobs folder. When I click the button nothing happens. I had fiddler running so I could see if a request was being sent. Nothing shows in fiddler. I am not sure why GetResultDataAsync is not firing at all.
Geoprocessor geoprocessorTask = sender as Geoprocessor;
geoprocessorTask.GetResultDataCompleted += GeoprocessorTask_GetResultDataCompleted;
geoprocessorTask.Failed += GeoprocessorTask_Failed;
geoprocessorTask.GetResultDataAsync("j0ecca8fcfee3406ba977cb29b53d09dd", "output"); I put in some exception handling in my code to see what is going wrong. I get an "object reference not set to an instance of an object" in this code.
foreach (GPParameter gpParameter in e.Results.OutParameters)
{
GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
foreach (Graphic graphic in gpLayer.FeatureSet.Features)
{
graphicsLayer.Graphics.Add(graphic);
}
}
... View more
05-24-2012
06:59 AM
|
0
|
0
|
2228
|
|
POST
|
Hi dbroux, I already have MessageBox.Show(e.JobInfo.JobStatus.ToString()); in my code for Geoprocessor_JobCompleted and it shows the esriJobSucceeded message. I have messageboxes in my GeoprocessorTask_GetResultDataCompleted so it will show me when that completes but I never get anything. Here is my output parameter which does not look like an issue to me. Parameter: output Data Type: GPRecordSet Display Name: output Direction: esriGPParameterDirectionOutput Default Value: Parameter Type: esriGPParameterTypeRequired Category: Thanks for your response.
... View more
05-24-2012
06:40 AM
|
0
|
0
|
2298
|
|
POST
|
Well I am not having much luck. I can't seem to retrieve my results from the GP Task. The GP Task runs fine and I do see the results in the jobs folder on the server. I then attempt to run a GetResultDataAsync to get the GPFeatureRecordSetLayer but it is getting hung up. It seems like my geoprocessorTask.GetResultDataCompleted is not firing as the completed or failed events never get triggered. Anyone see anything wrong in my code? This is the first time I try an Asynchronous request so there is verywell some user error involved here. I use the samples as a guide.
private void Geoprocessor_JobCompleted(object sender, JobInfoEventArgs e)
{
Geoprocessor geoprocessorTask = sender as Geoprocessor;
geoprocessorTask.GetResultDataCompleted += GeoprocessorTask_GetResultDataCompleted;
geoprocessorTask.Failed += GeoprocessorTask_Failed;
geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "output");
}
private void GeoprocessorTask_GetResultDataCompleted(object sender, GPParameterEventArgs e)
{
GraphicsLayer graphicsLayer = MapApplication.Current.Map.Layers["MyResultGraphicsLayer"] as GraphicsLayer;
GPFeatureRecordSetLayer gpLayer = e.Parameter as GPFeatureRecordSetLayer;
MessageBox.Show(gpLayer.FeatureSet.Count().ToString());
foreach (Graphic graphic in gpLayer.FeatureSet.Features)
{
graphicsLayer.Graphics.Add(graphic);
}
MessageBox.Show(graphicsLayer.Count().ToString());
this.dg.GraphicsLayer = graphicsLayer;
btnPoint.IsEnabled = true;
}
private void GeoprocessorTask_Failed(object sender, TaskFailedEventArgs e)
{
MessageBox.Show("Geoprocessing service failed: " + e.Error);
btnPoint.IsEnabled = true;
}
... View more
05-24-2012
06:12 AM
|
0
|
0
|
2298
|
|
POST
|
GraphicsLayer does not need to be part of map if there is no geometry. I did not know this. That should clear everything up. I will give it a try. Thanks!!!
... View more
05-23-2012
12:23 PM
|
0
|
0
|
2298
|
|
POST
|
It does require input and I have already used Fiddler to verify the rquest I am sending is correct. I changed my execution type to asynchronous now so I can see my results on the server. I am now trying to update my web app to use this service. I am stuck on the part you mentioned about the GPFeatureRecordSetLayer. I see examples on how to iterate the recordset to add as graphics. I just can't seem to figure out how to iterate the records to add to a list so I can populate a table since what i am returning are just statistics that will display in a report. GPFeatureRecordSetLayer gpLayer = e.Parameter as GPFeatureRecordSetLayer;
foreach (Graphic graphic in gpLayer.FeatureSet.Features)
{
}
... View more
05-23-2012
09:41 AM
|
0
|
0
|
2298
|
|
POST
|
Hi Jennifer- Thanks for the reply. When i run from the rest enpoint to the %SCRATCHWORKSPACE% i get results but they disappear from the jobs folder to check what is in the results table. I changed the output of the service to a dbf temporarily and I see my results fine. I get the messages seen below when running the gp fom rest. The gp service is synchrounous so the execute should be fine. I belive you are right with the GPFeatureRecordSetLayer. How do I go about that? Results: Messages: �?� esriJobMessageTypeInformative: Executing (HailAnalysis): HailAnalysis "Feature Set" "100 Miles" �?� esriJobMessageTypeInformative: Start Time: Wed May 23 11:06:24 2012 �?� esriJobMessageTypeInformative: Executing (Buffer): Buffer "Feature Set" D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\Buffer.shp "100 Miles" FULL ROUND NONE # �?� esriJobMessageTypeInformative: Start Time: Wed May 23 11:06:24 2012 �?� esriJobMessageTypeInformative: Succeeded at Wed May 23 11:06:25 2012 (Elapsed Time: 1.00 seconds) �?� esriJobMessageTypeInformative: Executing (Clip): Clip D:\agsResources\ArcSDE.sde\ArcSDE.A10ID.HailClaims D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\Buffer.shp D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\HailClaims_Clip.shp # �?� esriJobMessageTypeInformative: Start Time: Wed May 23 11:06:25 2012 �?� esriJobMessageTypeInformative: Reading Features... �?� esriJobMessageTypeInformative: Cracking Features... �?� esriJobMessageTypeInformative: Assembling Features... �?� esriJobMessageTypeInformative: Succeeded at Wed May 23 11:06:25 2012 (Elapsed Time: 0.00 seconds) �?� esriJobMessageTypeInformative: Executing (Summary Statistics): Statistics D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\HailClaims_Clip.shp D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\HailClaims_Clip_Statistics.dbf "LossAmt MEAN;ExpAmt MEAN;LossAmt SUM;ExpAmt SUM" LossDt �?� esriJobMessageTypeInformative: Start Time: Wed May 23 11:06:25 2012 �?� esriJobMessageTypeInformative: Succeeded at Wed May 23 11:06:25 2012 (Elapsed Time: 0.00 seconds) �?� esriJobMessageTypeInformative: Executing (Sort): Sort D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\HailClaims_Clip_Statistics.dbf D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\HailClaims_Clip_Statistics_S.dbf "FREQUENCY DESCENDING" UR �?� esriJobMessageTypeInformative: Start Time: Wed May 23 11:06:25 2012 �?� esriJobMessageTypeInformative: Succeeded at Wed May 23 11:06:25 2012 (Elapsed Time: 0.00 seconds) �?� esriJobMessageTypeInformative: Executing (Table Select): TableSelect D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\HailClaims_Clip_Statistics_S.dbf D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\scratch.gdb\Ouput "OID >= 5" �?� esriJobMessageTypeInformative: Start Time: Wed May 23 11:06:25 2012 �?� esriJobMessageTypeInformative: Succeeded at Wed May 23 11:06:26 2012 (Elapsed Time: 1.00 seconds) �?� esriJobMessageTypeInformative: Succeeded at Wed May 23 11:06:26 2012 (Elapsed Time: 2.00 seconds)
... View more
05-23-2012
08:48 AM
|
0
|
0
|
2298
|
|
POST
|
Hi- I created a geoprocessing service that outputs a table in the scratch GDB. I am trying to retrieve the results to diplay in a datagrid but I am having issues. I have tried many methods with no luck. Below I try to count the outparameters but it is always 0. Does anyone know how to retruieve the table data? private void GeoprocessorTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.GPExecuteCompleteEventArgs args) { btnPoint.IsEnabled = true; MessageBox.Show(args.Results.OutParameters.Count().ToString()); } Thanks!
... View more
05-23-2012
08:01 AM
|
0
|
16
|
8071
|
|
POST
|
The first thing you need to learn is how to create/deploy a custom layout. This link, Creating a Custom Layout, explains that process. You can place my code in different locations depending on where in the map you would like to see the measuring control panel. I used the accordian layout as my starting template. Create a copy of the accordian.xaml and name it whaterver you want. For my example You should find the area around line 571 that startes esri:map. This is where I implement my custom tools. Here is my code expanded a little so you can see where I implemented it. I actually have 2 tools in here. One is the measurinf tools and the other is a tranparency slide that changes the transparency of the selected layer. I changed both items to Visible so they will always show for you. You can take a look at the viewer help and samples for instructions to create a toggle to turn these on and off using an add-in. I'll be glad to answer any questions if I can. <esri:Map x:Name="Map" HorizontalAlignment="Stretch" IsLogoVisible="False" VerticalAlignment="Stretch"
Grid.ColumnSpan="2" Grid.RowSpan="3" WrapAround="True"
d:DataContext="{Binding Converter={StaticResource SampleGraphicsLayerConverter}, RelativeSource={RelativeSource Self}}"/>
<Grid Grid.Column="{Binding ElementName=SidePanelContainer, Path=Visibility, Converter={StaticResource VisibilityToIntConverter}}"
Grid.ColumnSpan="{Binding ElementName=SidePanelContainer, Path=Visibility, Converter={StaticResource VisibilityToIntConverter}, ConverterParameter='1,2'}" Grid.RowSpan="{Binding Visibility, ConverterParameter=1\,2, Converter={StaticResource VisibilityToIntConverter}, ElementName=FeatureDataGridContainer}">
<esri:MapProgressBar Map="{Binding ElementName=Map}" Width="250" Height="35" Style="{StaticResource MapProgressBarStyle}" Margin="10,5,0,2" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
<ContentControl x:Name="ScaleBarContainer"
Margin="20,0,0,2"
HorizontalAlignment="Left"
HorizontalContentAlignment="Stretch"
VerticalAlignment="Bottom"
Foreground="WhiteSmoke">
<ContentControl.Effect>
<DropShadowEffect BlurRadius="10" ShadowDepth="2" Opacity="1" Direction="300" />
</ContentControl.Effect>
</ContentControl>
<ContentControl x:Name="AttributionDisplayContainer"
HorizontalAlignment="Right" VerticalAlignment="Bottom"
Margin="0,0,6,2"/>
<!--Measuring Tools-->
<Grid x:Name="MeasureBox" HorizontalAlignment="Right" VerticalAlignment="Top" Width="Auto" Height="Auto" Margin="10" Visibility="Visible">
<Border Style="{StaticResource GlassyBorder}" Padding="10,3,10,3" Opacity="1">
<!--<Border.Effect>
<DropShadowEffect />
</Border.Effect>-->
<StackPanel >
<TextBlock Text="Measuring Tools" Foreground="White" FontSize="14" FontWeight="Bold" Margin="4" />
<TextBlock Text="Select Units:" Foreground="White" FontSize="12" Margin="2" />
<ComboBox x:Name="UnitCombo" Foreground="White" Margin="0,0,0,4" >
<ComboBox.Items>
<ComboBoxItem Content="Feet" IsSelected="True" Foreground="Black"/>
<ComboBoxItem Content="Meters" Foreground="Black"/>
<ComboBoxItem Content="Miles" Foreground="Black"/>
</ComboBox.Items>
</ComboBox>
<ComboBox x:Name="AreaCombo" Foreground="White">
<ComboBox.Items>
<ComboBoxItem Content="SquareFeet" IsSelected="True" Foreground="Black"/>
<ComboBoxItem Content="SquareMeters" Foreground="Black"/>
<ComboBoxItem Content="SquareMiles" Foreground="Black"/>
</ComboBox.Items>
</ComboBox>
<Rectangle Margin="0,10,0,10" Fill="White" Height="2" HorizontalAlignment="Stretch" />
<Button Margin="0,0,0,2"
Content="Length(Line)" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<esri:MeasureAction
AreaUnit="{Binding ElementName=AreaCombo, Path=SelectedItem.Content}"
DisplayTotals="True"
DistanceUnit="{Binding ElementName=UnitCombo, Path=SelectedItem.Content}"
MapUnits="Meters"
MeasureMode="Polyline"
FillSymbol="{StaticResource DefaultFillSymbol}"
TargetName="Map"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button Margin="0,2,0,2"
Content="Radius(Circle)" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<esri:MeasureAction
AreaUnit="{Binding ElementName=UnitCombo, Path=SelectedItem.Content}"
DisplayTotals="True"
DistanceUnit="{Binding ElementName=UnitCombo, Path=SelectedItem.Content}"
MapUnits="Meters"
MeasureMode="Radius"
FillSymbol="{StaticResource DefaultFillSymbol}"
TargetName="Map"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button Margin="0,2,0,2"
Content="Area(Polygon)" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<esri:MeasureAction
AreaUnit="{Binding ElementName=AreaCombo, Path=SelectedItem.Content}"
DisplayTotals="True"
DistanceUnit="{Binding ElementName=UnitCombo, Path=SelectedItem.Content}"
MapUnits="Meters"
MeasureMode="Polygon"
FillSymbol="{StaticResource DefaultFillSymbol}"
TargetName="Map"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
</Border>
</Grid>
<!--Transparency Slider-->
<Grid x:Name="TransparencyBox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="Auto" Height="Auto" Margin="10" Visibility="Visible">
<Border Style="{StaticResource GlassyBorder}" Padding="10,3,10,3" Opacity="1">
<!--<Border.Effect>
<DropShadowEffect />
</Border.Effect>-->
<StackPanel Background="Transparent" Margin="0,0,0,0" HorizontalAlignment="Right" VerticalAlignment="Center">
<TextBlock Text="Layer Transparency" Foreground="White" FontSize="14" FontWeight="Bold" Margin="4" />
<Slider Height="23" Width="100" Name="slider1" Minimum="0" Maximum="1" Value="{Binding Path=SelectedLayer.Opacity, Mode=TwoWay, Source={StaticResource MapApplication}}" IsDirectionReversed="False" />
</StackPanel>
</Border>
</Grid>
</Grid>
... View more
05-17-2012
04:38 AM
|
0
|
0
|
1235
|
|
POST
|
I am having an issue with the Auto Update settings in the Viewer. I set all the appropriate auto update settings for all my layers ranging from 2 mnute to 10 minute updates. I publish the map and everything works as planned. If I go back into the viewer to make a change, randomly a layers auto update will be change back to the default 30 second update. There is no rhyme or reason why it does this or what layer it does this on. Now everytime I go in to make a change, before I publish, I have to go into to the configuratyion of every layer to make sure the settings are correct. Not fun... Is this a known bug? Thanks..
... View more
05-15-2012
05:21 AM
|
0
|
0
|
565
|
|
POST
|
I have developed a measuring tool by utilizing a custom layout template. I went this route because I liked the functionality of seeing the measurements on individual line segments. I also created a quick add-in that allows the Measuring Panel to be opened and closed but it is not necesary. Yuo can change the visibility of the MeasureBox Data Grid to Visible and it will remian open all the time. I've included a picture of this tool. [ATTACH=CONFIG]14300[/ATTACH] Custom Layout Measuring Code <Grid x:Name="MeasureBox" HorizontalAlignment="Right" VerticalAlignment="Top" Width="Auto" Height="Auto" Margin="10" Visibility="Collapsed">
<Border Style="{StaticResource GlassyBorder}" Padding="10,3,10,3" Opacity="1">
<StackPanel >
<TextBlock Text="Measuring Tools" Foreground="White" FontSize="14" FontWeight="Bold" Margin="4" />
<TextBlock Text="Select Units:" Foreground="White" FontSize="12" Margin="2" />
<ComboBox x:Name="UnitCombo" Foreground="White" Margin="0,0,0,4" >
<ComboBox.Items>
<ComboBoxItem Content="Feet" IsSelected="True" Foreground="Black"/>
<ComboBoxItem Content="Meters" Foreground="Black"/>
<ComboBoxItem Content="Miles" Foreground="Black"/>
</ComboBox.Items>
</ComboBox>
<ComboBox x:Name="AreaCombo" Foreground="White">
<ComboBox.Items>
<ComboBoxItem Content="SquareFeet" IsSelected="True" Foreground="Black"/>
<ComboBoxItem Content="SquareMeters" Foreground="Black"/>
<ComboBoxItem Content="SquareMiles" Foreground="Black"/>
</ComboBox.Items>
</ComboBox>
<Rectangle Margin="0,10,0,10" Fill="White" Height="2" HorizontalAlignment="Stretch" />
<Button Margin="0,0,0,2"
Content="Length(Line)" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<esri:MeasureAction
AreaUnit="{Binding ElementName=AreaCombo, Path=SelectedItem.Content}"
DisplayTotals="True"
DistanceUnit="{Binding ElementName=UnitCombo, Path=SelectedItem.Content}"
MapUnits="Meters"
MeasureMode="Polyline"
FillSymbol="{StaticResource DefaultFillSymbol}"
TargetName="Map"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button Margin="0,2,0,2"
Content="Radius(Circle)" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<esri:MeasureAction
AreaUnit="{Binding ElementName=UnitCombo, Path=SelectedItem.Content}"
DisplayTotals="True"
DistanceUnit="{Binding ElementName=UnitCombo, Path=SelectedItem.Content}"
MapUnits="Meters"
MeasureMode="Radius"
FillSymbol="{StaticResource DefaultFillSymbol}"
TargetName="Map"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button Margin="0,2,0,2"
Content="Area(Polygon)" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<esri:MeasureAction
AreaUnit="{Binding ElementName=AreaCombo, Path=SelectedItem.Content}"
DisplayTotals="True"
DistanceUnit="{Binding ElementName=UnitCombo, Path=SelectedItem.Content}"
MapUnits="Meters"
MeasureMode="Polygon"
FillSymbol="{StaticResource DefaultFillSymbol}"
TargetName="Map"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
</Border>
</Grid> Code in Add-In to toggle toll on/off Measuring tool in layout. namespace MeasurementTool.AddIns
{
[Export(typeof(ICommand))]
[DisplayName("Measuring Tools")]
[ESRI.ArcGIS.Client.Extensibility.Description("Click to show or hide measuring tools.")]
public class ToggleLayoutObject : ICommand
{
private FrameworkElement objectToToggle;
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
if (objectToToggle == null)
objectToToggle = MapApplication.Current.FindObjectInLayout("MeasureBox") as FrameworkElement;
if (objectToToggle != null)
objectToToggle.Visibility = objectToToggle.Visibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;
}
}
}
... View more
05-14-2012
05:50 AM
|
0
|
0
|
3179
|
|
POST
|
Craig- Do you happen to know if it keeps the same orange glow affect when selecting the items? Thanks.
... View more
04-27-2012
11:21 AM
|
0
|
0
|
2410
|
|
POST
|
2. Find the differences in a python set. This is the fastest by a long way (milliseconds for the whole thing). The catch is that you still have to read the tables once each to make the sets and write out a selected set. But it will still be less than minute or two. This sounds like an ideal chioce for me but as I said my python experience is limited. Do you happen to know of any samples that show how to populate a set from a table in sde? Thanks!
... View more
04-24-2012
06:40 AM
|
0
|
0
|
1074
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-21-2026 06:15 AM | |
| 4 | 03-12-2025 11:01 AM | |
| 3 | 01-08-2025 09:26 AM | |
| 1 | 01-08-2025 07:19 AM | |
| 1 | 12-06-2024 04:52 AM |
| Online Status |
Offline
|
| Date Last Visited |
2 weeks ago
|