1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    17
    Vote Rating
    0
    Sam007 is on a distinguished road

      0  

    Default Modeling OpenLayers code to GeoExt Action

    Modeling OpenLayers code to GeoExt Action


    I am new to ExtJS and I have the following openlayers code and I am trying to model it into GeoExt Action. The purpose of the code is to create a user drawn Vector Layer polygon, which will fetch the feature attributes of all the WMS feature layer, contained in the user defined polygon.


    Here is the code,


    Code:
        pySelCtrl = new
        OpenLayers.Control.DrawFeature(selectedLayer, OpenLayers.Handler.Polygon, {
                             geodesic: true,
                             handlerOptions: {
                                 citeCompliant: false
                             }
                         }); // selected layer is an empty vector layer that use
        for drawing selected feature on and for drawing control
        
                         pySelCtrl.events.register("featureadded", this,
        function (e) {
                             clearData(); // housekeeping (clean up previous
        queries, delete all vectors from selectedLayer)
                             var pfilter = new OpenLayers.Filter.Spatial({
                                     type: OpenLayers.Filter.Spatial.INTERSECTS,
                                     value: e.feature.geometry
                                 });
        //                    This next piece of code is using application logic
        to find out which fields to fetch back from the server. If you dont
        specify properynames, it will return all of them
                             var propNames = [];
                             var layerNode = getLayerNode(combo.value); // this
        returns application metadata about the layer to query
                             var spatialQueryNode =layerNode.spatialQuery[0]; //
        get the list of fields to return from application metadata
                             for (var i = 0; i < spatialQueryNode.fields.length;
        i++) {
                                 propNames.push(spatialQueryNode.fields[i].id);
                             }
        //
                            if (spatialQueryNode.highlightOnMap)
        propNames.push("SHAPE");     // fetch back geometryif I am going to draw
        the on the map
        
        // This read queries the server.
                             wfsProtocol[combo.value].read({
                                 filter:  pfilter,
                                 propertyNames:propNames,
                                 callback: processSpatialQuery,
                                 scope: strategy
                             });
                         });
    I do have the Polygon Draw Action Tool, not sure where to add the eventListener and the rest of the code. Here is my code for the Polygon Draw Tool,


    Code:
        action = new GeoExt.Action({
                text: "draw poly",
                control: new OpenLayers.Control.DrawFeature(
                    features, OpenLayers.Handler.Polygon
                ),
                map: map,
                // button options
                toggleGroup: "draw",
                allowDepress: false,
                tooltip: "draw polygon",
                // check item options
                group: "draw"
            });
            actions["draw_poly"] = action;
            toolbarItems.push(action);

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,999
    Vote Rating
    456
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Are you offering this code, or do you need info?

    Scott.

  3. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    17
    Vote Rating
    0
    Sam007 is on a distinguished road

      0  

    Default


    I have the code but I am confused as to how I should place it in the GeoExt.Action so that I can call it when the tool draws the desired polygon. I am using the ExtJS for the first time, so needed some assistance.

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,999
    Vote Rating
    456
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    I am not sure you provided enough information .. let me take a stab

    You created an instance : var action = new GeoExt.Action({ .. }); // with properties set

    Does this evaluate in console?
    console.log(action);

    Do you have the library included in your uses? Are you receiving errors?

    Scott.

  5. #5
    Sencha User
    Join Date
    Sep 2012
    Posts
    17
    Vote Rating
    0
    Sam007 is on a distinguished road

      0  

    Default


    hey Scott sorry about the incomplete code. Here is the complete code (The action object is on line 79). You can also see the live demo on this link, http://128.196.142.12/geo/test/prac.html

    The console.log(action) returns a object. It is really big one. Even u can see it now in the the link I sent. The short version of the object looks like this,
    Object { control={...}, activateOnEnable=false, deactivateOnDisable=false, more...}

Thread Participants: 1

Tags for this Thread