Easty
Easty

Reputation: 387

changing the width of an esri polyline

Below you will find javascript code for creating a map and creating a ArcGISDynamicMapServiceLayer. This ArcGISDynamicMapServiceLayer holds 16 layers. Layer 2 with id of 1 is a esriGeometryPolyline layer. The lines on this layer are not thick enough when you lay it on the map. Is it possible to get that layer out of the ArcGISDynamicMapServiceLayer object and widen the lines. I have search the normal forums and google but not found anything that can help me.

var visible = [0,1,2];
    var initialExtent = new Extent({"xmin":455248.7328447895,"ymin":404516.307641385,"xmax":532048.7328447895,"ymax":484516.307641385,"spatialReference":{"wkid":27700}});
              myMap = new Map("mainMap", {
                extent: initialExtent
              });

      var baseLayer = new ArcGISTiledMapServiceLayer("http://************/arcgis/rest/services/Basemap/*********/MapServer");
      myMap.addLayer(baseLayer);

      dojo.connect(myMap, "onUpdateStart", showLoading);
      dojo.connect(myMap, "onUpdateEnd", hideLoading);

      var imageParameters = new esri.layers.ImageParameters();

      imageParameters.transparent=true;

      layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://*********************/arcgis/rest/services/***********/MapServer", {"imageParameters":imageParameters});
      layer.setOpacity(0.8);
      myMap.addLayer(layer);

      layer.setVisibleLayers(visible);

Upvotes: 0

Views: 604

Answers (1)

GeographicPerspective
GeographicPerspective

Reputation: 219

You can not adjust the line width of a DynamicMapServiceLayerwith JS code.

You can increase a line width in two ways.

1) Edit the map service MXD in arcmap then republish the service with a thicker line.

2) Consume the layers as FeatureLayer instead of a DynamicMapService. You can control all aspects of a FeatureLayer. Adding a slash and a layer id to the end of a DynmaicMapService URL will make the layer a FeatureLayer.

require([
    "esri/layers/FeatureLayer", "esri/renderers/SimpleRenderer", "esri/symbols/SimpleLineSymbol", "esri/Color", ... 
], function(FeatureLayer, SimpleRenderer, SimpleLineSymbol, Color, ... ) {

    var featureLayer = new FeatureLayer(""http://*********************/arcgis/rest/services/***********/MapServer/2",{
        mode: FeatureLayer.MODE_ONDEMAND,
        outFields: ["*"]
    });
    var symbol = new SimpleLineSymbol(
        SimpleLineSymbol.STYLE_DASH,
        new Color([255,0,0]),
        3
    );
    var renderer = new SimpleRenderer(symbol);
    featureLayer.setRenderer(renderer);

    ...
});

Upvotes: 1

Related Questions