empicard

copy features from one layer to another?

Discussion created by empicard on Aug 27, 2012
Latest reply on Aug 29, 2012 by geos_rfleet
I have polygons in one layer, I'd like a user to be able to select them, and copy them into a new layer, and hopefully dissolve, making aggregate polygons.

I'm using the draw toolbar to create the selection polygon...

        tb = new esri.toolbars.Draw(map);
        tb.activate(esri.toolbars.Draw.POLYGON);
        dojo.connect(tb, "onDrawEnd", addGraphic);



I can query the polygon layer...

      function addGraphic(geometry){
        tb.deactivate();
        var polySymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,255]), 2), new dojo.Color([255,255,0,0.25]));
        var polyGraphic = new esri.Graphic(geometry, polySymbol);
        map.graphics.add(polyGraphic);
        var queryPolyTask = new esri.tasks.QueryTask(serverVar + "/ArcGIS/rest/services/IndivTerritoriesOnly/CurrentAll/MapServer/1");
        var polyQuery = new esri.tasks.Query();
        polyQuery.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;
        polyQuery.outSpatialReference = {"wkid": 102100};
        polyQuery.returnGeometry = true;
        polyQuery.geometry = geometry;
        polyQuery.outFields = ["ziptext"];
        queryPolyTask.execute(polyQuery); 
        dojo.connect(queryPolyTask, "onComplete", function(results){
          doZipManager(results);
        });
        };


and I've created a graphic layer to display it.

      function doZipManager(results){
        var items = dojo.map(results,function(result){
          var graphic = result.feature;
          zoomSelExtent = graphic.geometry.getExtent(); 
          graphic.setSymbol(symbol);
          map.graphics.add(graphic);
          return result.feature.attributes;
        });
        var selectedZipGraphic = new esri.layers.GraphicsLayer();
        var selectedZipSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,122,122]), 2), new dojo.Color([180,200,0,0.25]));
        var zipResultFeatures = results.features;
        selectedZipGraphic.setRenderer(selectedZipSymbol);
        dojo.forEach(zipResultFeatures, function (feature) {
            var graphic = feature;
            graphic.setSymbol(selectedZipSymbol);
            selectedZipGraphic.add(graphic);
            items.push(feature.attributes);
        });
        map.addLayer(selectedZipGraphic);

      };



But is it possible to save this selection for long term use?  I've seen suggestions of saving a cookie or using local storage, but thats just not working for me. 
I'd like to save these selections in the database, if possible.  This is to be a distributed app, and the central office would like access to what users are creating. 
I dont care if its a feature class or a table.  Creating a webservice has been suggested, but I can't even wrap my head around it. 
I'm using Javascript and HTML, SQL Server 2008.  I dont know anything about .net, and I don't have time to start learning it now.

Thank you to any and all insight.
Really in a bind here....
E

Outcomes