Select to view content in your preferred language

Edit widget - color off the selection response

1868
3
Jump to solution
01-02-2017 04:19 AM
KimBülow
Occasional Contributor

Edit widget - color off the selection response   Happy New Year to all of you.    Is there some one who knows how to change the color selection responses in a line so that it is Red as standard? and not cyan blue   In select widget i can change the color of a selection line, but not in the edit widget?   is there a way change it in a config file, we use ESRI web appbuilder developer edition 2.2

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Kim,

   The selection symbol is set per layer normally so it will take some code changes in the edit widget to handle this:

define([
    'esri/Color',
    'esri/symbols/SimpleMarkerSymbol',
    'esri/symbols/SimpleLineSymbol',
    'esri/symbols/SimpleFillSymbol',
....
Color, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol
.....


      beginEditingByFeatures: function(features, featureLayer) {
        if(features.length === 0) {
          return;
        }

        var firstFeaturePoint;
        var firstFeature = features[0];
        if(firstFeature.geometry.type === 'point') {
          firstFeaturePoint = firstFeature.geometry;
        } else {
          firstFeaturePoint = firstFeature.geometry.getExtent().getCenter();
        }

        this._createOverDef.then(lang.hitch(this, function() {
          // active if state is deactive
          if(this.state !== 'active') {
            this.widgetManager.activateWidget(this);
          }

          // clear selection for all featureLayers.
          array.forEach(this._jimuLayerInfos.getLayerInfoArray(), function(jimuLayerInfo) {
            if(jimuLayerInfo.layerObject && jimuLayerInfo.layerObject.clearSelection) {
              SelectionManager.getInstance().clearSelection(jimuLayerInfo.layerObject);
            }
          }, this);

          // var query = new Query();
          // query.where = prepareWhereExpression();
          // featureLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW, lang.hitch(this, function(features) {
          // }));
//My edit to change selection Color
          var type = featureLayer.geometryType;
          var selectionColor = new Color("#FF0000");
          var defaultPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE,
            16, null, selectionColor);
          var defaultLineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
            selectionColor, 2);
          var defaultFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_NULL,
            defaultLineSymbol, selectionColor);

          if (type === 'esriGeometryPoint') {
            featureLayer.setSelectionSymbol(defaultPointSymbol);
          } else if (type === 'esriGeometryPolyline') {
            featureLayer.setSelectionSymbol(defaultLineSymbol);
          } else if (type === 'esriGeometryPolygon') {
            featureLayer.setSelectionSymbol(defaultFillSymbol);
          }
          SelectionManager.getInstance().setSelection(featureLayer, features).then(lang.hitch(this, function() {‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
//end my edits
......‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Kim,

   The selection symbol is set per layer normally so it will take some code changes in the edit widget to handle this:

define([
    'esri/Color',
    'esri/symbols/SimpleMarkerSymbol',
    'esri/symbols/SimpleLineSymbol',
    'esri/symbols/SimpleFillSymbol',
....
Color, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol
.....


      beginEditingByFeatures: function(features, featureLayer) {
        if(features.length === 0) {
          return;
        }

        var firstFeaturePoint;
        var firstFeature = features[0];
        if(firstFeature.geometry.type === 'point') {
          firstFeaturePoint = firstFeature.geometry;
        } else {
          firstFeaturePoint = firstFeature.geometry.getExtent().getCenter();
        }

        this._createOverDef.then(lang.hitch(this, function() {
          // active if state is deactive
          if(this.state !== 'active') {
            this.widgetManager.activateWidget(this);
          }

          // clear selection for all featureLayers.
          array.forEach(this._jimuLayerInfos.getLayerInfoArray(), function(jimuLayerInfo) {
            if(jimuLayerInfo.layerObject && jimuLayerInfo.layerObject.clearSelection) {
              SelectionManager.getInstance().clearSelection(jimuLayerInfo.layerObject);
            }
          }, this);

          // var query = new Query();
          // query.where = prepareWhereExpression();
          // featureLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW, lang.hitch(this, function(features) {
          // }));
//My edit to change selection Color
          var type = featureLayer.geometryType;
          var selectionColor = new Color("#FF0000");
          var defaultPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE,
            16, null, selectionColor);
          var defaultLineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
            selectionColor, 2);
          var defaultFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_NULL,
            defaultLineSymbol, selectionColor);

          if (type === 'esriGeometryPoint') {
            featureLayer.setSelectionSymbol(defaultPointSymbol);
          } else if (type === 'esriGeometryPolyline') {
            featureLayer.setSelectionSymbol(defaultLineSymbol);
          } else if (type === 'esriGeometryPolygon') {
            featureLayer.setSelectionSymbol(defaultFillSymbol);
          }
          SelectionManager.getInstance().setSelection(featureLayer, features).then(lang.hitch(this, function() {‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
//end my edits
......‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
KimBülow
Occasional Contributor

Thanks i try to fix the code

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Kim,

  When a person responds with an reply that you will use as the answer to you question you should not mark the post as assumed answered, you should mark that reply as the correct answer by clicking on the "Mark Correct" on that reply. Using the assumed answered is for when you find an answer on your own or the question is no longer ans issue.