How to change feature layer style using its parameters

4440
15
Jump to solution
11-19-2016 10:55 AM
SabbiuShah
New Contributor II

This is the code that I have written till now.

require([
   "esri/Map",
   "esri/views/MapView",
   "esri/layers/MapImageLayer",
   "esri/renderers/SimpleRenderer",
   "esri/symbols/SimpleFillSymbol",
   "dojo/domReady!"
],
function(
   Map, MapView, MapImageLayer, SimpleRenderer, SimpleFillSymbol
) {

   var permitsLyr = new MapImageLayer({
   url: "http://apps.geoportal.icimod.org/ArcGIS/rest/services/Nepal/District/MapServer",
   sublayers: [
   {
      id: 1,
      visible: true,
   },
   {
      id: 0,
      visible: true,
   }
   ],

});

/*****************************************************************
* Add the layer to a map
*****************************************************************/
var map = new Map({
   // basemap: "dark-gray",
   layers: [permitsLyr]
});

var view = new MapView({
   container: "viewDiv",
   map: map
});

/*****************************************************************
* Animate to the layer's full extent when the layer loads.
*****************************************************************/
permitsLyr.then(function() {
   view.goTo(permitsLyr.fullExtent);
});
});

Now, I would like to change default renderer given in the District - Nepal/District  as 

Drawing Info:

      Renderer:
        Simple Renderer:
        Symbol:

                        Simple Fill Symbol:

          Style: esriSFSSolid, Color: [Undefined]
          Outline:

                                    Simple Line Symbol:

            Style: esriSLSSolid, Color: [78, 78, 78, 255], Width: 1
        Label:
        Description:
        Transparency: 0
        Labeling Info: N/A

    How do I change the default color and style for it? Also, using its attribute "DIST_CODE", I also want to apply different color for different polygons.

    I am new to this field. So, help me out.

    0 Kudos
    15 Replies
    SabbiuShah
    New Contributor II

    Yeah.

    Actually, the discussion with Saroj was helpful. So, I asked everything in the same. I shall later edit the title and publish my codes accordingly.

    Thanks for your concern

    0 Kudos
    SarojThapa1
    Occasional Contributor III

    Glad I could help you.

    0 Kudos
    SarojThapa1
    Occasional Contributor III

    Have a look at this sample.     Labeling features on the client | ArcGIS API for JavaScript 3.18 

    I usually label the features before publishing the maps in the ArcGIS Server. That way I can call all the maps along with labels using ArcGISDynamicMapServiceLayer module.

    0 Kudos
    SabbiuShah
    New Contributor II

    In case of ArcGIS API for JavaScript 4.1 what do I need to look into? It says that, it supports only for sceneview ..

    Yeah, in the mapserver it already have the labeling information, but it is not showing on my side. So, I thought I shall label it myself.

    0 Kudos
    SarojThapa1
    Occasional Contributor III

    You can label it yourself programmatically. I use ArcGIS API 3.18 because I work with 2D maps and I need Editing functionalities that are fully supported by version 3.18. I am not sure about 4.1 as far as labeling programatically is concerned. But I would guess the codes should be very similar in 3.18 and 4.11. 

    SabbiuShah
    New Contributor II

    Okay! I will look into it.

    What are the steps to create MapServer in our own server? What kind of data do I need to have?

    0 Kudos