Select to view content in your preferred language

SketchGeometryCollectionMethod not working in 10.2

4236
7
08-19-2014 03:51 AM
AndrewCorcoran
Deactivated User

I have a custom solution that worked at ArcGIS Mobile 10.0 that I'm now porting to 10.2. It uses the SketchGeometryCollectionMethod. However I can't seem to get this working at 10.2 at all. The usual map window does not display to allow a geometry to be inputted. The following code used to display a map window with the current extent:

Feature f = new Feature(m_mobileSettingsFeatureType, null);

m_geometryCollection.StartGeometryCollection(f.Geometry);

Also the GeometryCollectionPage property has been removed.

Any ideas?

0 Kudos
7 Replies
MattFlowerday
Deactivated User

Any luck Andrew? we encountered the same issue

0 Kudos
MattFlowerday1
Occasional Contributor

Andrew - below is some sample code- this is as far as we got.  It fires up a sketch geometry page but does allow the user to start collecting geometry......

// Create a new Feature, this will automatically call StartEditing on this feature

FeatureToCreate = new Feature(_featureSourceInfo.FeatureTypes.FirstOrDefault(), null);

                //THIS IS NOT WORKING- NOT CAPTURING DATA

_sketchGeometryCollectionMethod = new SketchGeometryCollectionMethod();

_sketchGP = new SketchGeometryPage();

_sketchGP.ClickBack += GeometryCollectionPageClickBack;

_sketchGP.ClickNext += SketchGeometryCollectionMethodOnCompleted;

                MobileApplication.Current.Transition(_sketchGP);

_sketchGeometryCollectionMethod.StartGeometryCollection(_sketchGP.Geometry);

0 Kudos
AndrewCorcoran
Deactivated User

Hi Matt,

I ended up creating my own MobileApplicationPage sub-class and adding a ESRI.ArcGIS.Mobile.Client.Controls.GeometryCollectionControl to it. This provides all the methods needed to get a geometry. I couldn't work out how to remove the geometry collection methods panel from the left hand side though.

As the API documentation is missing the 'ESRI.ArcGIS.Mobile.Client' assembly I found the  JetBrains dotPeek freeware an essential tool to digging through the 'ESRI.ArcGIS.Mobile.Client' and 'ESRI.ArcGIS.Mobile' dlls and working out what UI components are available and also how the code works underneath.

Here is some code:

// This code creates the view model

Feature feature = new Feature(featureType, null);

GeometryCollectionViewModel model = new GeometryCollectionViewModel(feature, new ObservableCollection<GeometryCollectionMethod>());

// Then in the custom page set the view model on the GeometryCollectionControl

control.GeometryCollectionViewModel = model;

/// <summary>

/// Whether the current geometry displayed on this page is valid.

/// </summary>

public Boolean IsGeometryValid

{

    get

    {

        GeometryCollectionViewModel viewModel = _geometryCollectionControl.GeometryCollectionViewModel;

        GeometryCollectionMethod method = viewModel.GetCollectionMethodInProgress();

        if (method != null && method.Geometry != null)

        {

            return method.Geometry.IsValid;

        }

        return false;

    }

}

/// <summary>

/// The geometry that has been entered on this page.

/// </summary>

public Geometry Geometry

{

    get

    {

        GeometryCollectionViewModel viewModel = _geometryCollectionControl.GeometryCollectionViewModel;

        GeometryCollectionMethod method = viewModel.GetCollectionMethodInProgress();

        if (method != null)

            return method.Geometry;

        else

            return null;

    }

}

Hope this helps 🙂

0 Kudos
MattFlowerday1
Occasional Contributor

Awesome Thanks Andrew could you post your definition of control?

// Then in the custom page set the view model on the GeometryCollectionControl

                control.GeometryCollectionViewModel = model;

0 Kudos
AndrewCorcoran
Deactivated User

Here is the XAML for my custom page which defines the '_geometryCollectionControl':

<ArcGISMobileApplication:MobileApplicationPage

x:Class="WCNS.Mobile.Pages.CollectFeatureGeometryPage"

xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml

xmlns:ArcGISMobileApplication="clr-namespace:ESRI.ArcGIS.Mobile.Client;assembly=ESRI.ArcGIS.Mobile.Client"

xmlns:ArcGISMobileControls="clr-namespace:ESRI.ArcGIS.Mobile.Client.Controls;assembly=ESRI.ArcGIS.Mobile.Client">

<Grid>

<ArcGISMobileControls:GeometryCollectionControl x:Name="_geometryCollectionControl"></ArcGISMobileControls:GeometryCollectionControl>

</Grid>

</ArcGISMobileApplication:MobileApplicationPage>

Then in the code behind:

partial class CollectFeatureGeometryPage : MobileApplicationPage

{

    public CollectFeatureGeometryPage(GeometryCollectionViewModel viewModel)

        this._geometryCollectionControl.GeometryCollectionViewModel = viewModel;

}

0 Kudos
LeighHunt1
Deactivated User

Hi Andrew,

Any chance you would be able to supply a project with your working code? I tried to merge the code above with one of the samples, and didn't manage to get the geometry capture working - instead it just goes to the newly created blank page.

Code: leighghunt/SimpleDataCollectionExtension at dev-merge-attempt-1 · GitHub

I'm wondering if it is possible to enable the user to go straight to the collection of the geometry - e.g. bypass the feature attributes edit page?

Cheers,

Leigh.

0 Kudos
MattFlowerday1
Occasional Contributor

Hi Andrew, having another crack at this, getting closer, but still can't get it to collect any geometries.  We are just using the SketchGeometryPage as opposed to building a new page.

                    // Create a new Feature, this will automatically call StartEditing on this feature

                    FeatureToCreate = new Feature(_featureSourceInfo.FeatureTypes.FirstOrDefault(), null);

                    SetDefaultValues();

                    GeometryCollectionViewModel _geometryCollectionViewModel = new GeometryCollectionViewModel(FeatureToCreate, new ObservableCollection<GeometryCollectionMethod>());

                    GeometryCollectionControl control = new GeometryCollectionControl();

                    control.GeometryCollectionViewModel = _geometryCollectionViewModel;

                  SketchGeometryPage _sketchGP = new SketchGeometryPage();

                    _sketchGP.ClickBack += new EventHandler(EditFeatureAttributesPageClickCancel);

                    _sketchGP.ImageSource = ImageSource;

                    _sketchGP.Title = "Add " + _layerName.TrimEnd('s');

                    _sketchGP.Note = "Create " + _layerName.TrimEnd('s') + " by digitizing on the map";

                    _sketchGP.ClickNext += new EventHandler(EditFeatureAttributesPageClickOk);

                    _sketchGeometryCollectionMethod = new SketchGeometryCollectionMethod();

                    _sketchGeometryCollectionMethod.StartGeometryCollection(_sketchGP.Geometry);

                    MobileApplication.Current.Transition(_sketchGP);

0 Kudos