Adding Feature Layer Causes issues

Discussion created by VinayBa on Aug 31, 2013
Latest reply on Sep 3, 2013 by VinayBa
When i create map object using ArcGISDynamicMapServiceLayer then things work fine but since i need lot of graphics and want to handle user interactions on map so i want to use feature layer to my map but when i add feature layer the browser hangs.

Please let me know what could be the issue how can i avoid feature layer from hanging my Browser.What actually happens when i add Feature Layer does the map re render with new data , what could be the issue with Feature Layer service .

My Code

<!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Feature Layer Only Map</title>
    <link rel="stylesheet" href="">
      html, body, #map {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
    <script src=""></script>

 var map;
 function init(){
     map = new esri.Map("map");
     var layer = new esri.layers.ArcGISDynamicMapServiceLayer("");
     var url = "";
     var info_content = "<table><tr><td><b>COUNTRY :</b></td><td style='text-align:right'>${COUNTRY}</td></tr></table>";
     var infoTemplate1 = new esri.InfoTemplate("${COUNTRY}", info_content);
     var fl = new esri.layers.FeatureLayer(url, {
    id: "world-regions",
    infoTemplate: infoTemplate1

    var queryTask = new esri.tasks.QueryTask(url);

      //build query filter
      var query = new esri.tasks.Query();
      query.returnGeometry = true;
                        query.where = "COUNTRY='India'";
      infoTemplate = new esri.InfoTemplate("Alert", "Alert for Re-insurance");
      dojo.connect(queryTask, "onComplete", function(featureSet) {
          //alert('calling queryTask'+featureSet);
         /*var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_FORWARD_DIAGONAL, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.5]));
         var symbol0 = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 0, 0, 0.9]));
         //QueryTask returns a featureSet.  Loop through features in the featureSet and add them to the map.
          var graphic = feature;
     require(["dojo/on", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "dojo/_base/Color", "esri/graphic"], function(on, SimpleFillSymbol, SimpleLineSymbol, Color, Graphic) {
                    on(fl, "click", function(evt) {
                       console.log(" on click mehtod");
                        // clears current selection
                        // create new graphic with selected graphic's geometry
      alert("evt.graphic.geometry "+evt.graphic.geometry);
                        var graphic = new Graphic(evt.graphic.geometry);
                        alert("graphic "+graphic);
                        // create a new symbol for the graphic
                        var symbol0 = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 0, 0, 0.9]));
                        // add symbol to the graphic
                        // add the graphic to the map   
    } catch(e){
        console.log(" exception occured"+e);
    <div id="map"></div>

The Rest service of Feature Layer

Name: World_Countries_v3

Display Field: COUNTRY

Type: Feature Layer

Geometry Type: esriGeometryPolygon

Description: World Countires Map (v3) with the Display field as ISO3A. No changes to the data from V1.

Definition Expression:

Copyright Text:

Default Visibility: true

MaxRecordCount: 1000

Supported Query Formats: JSON, AMF

Min Scale: 0

Max Scale: 0

Supports Advanced Queries: false

Supports Statistics: false

Has Labels: false

Can Modify Layer: true

Can Scale Symbols: false


    XMin: -179.99999999990004
    YMin: -89.99999999990001
    XMax: 180.00000000010002
    YMax: 83.66549107605236
    Spatial Reference: 4326  (4326)

Drawing Info:

        Simple Renderer:
            Style: esriSFSSolid
            Color: [206, 191, 242, 255]
                Style: esriSLSSolid
                Color: [110, 110, 110, 255]
                Width: 0 Label:
        Description: Transparency: 0
    Labeling Info:

HasZ: false

HasM: false

Has Attachments: false

HTML Popup Type: esriServerHTMLPopupTypeAsHTMLText

Type ID Field: null


    FID ( type: esriFieldTypeOID , alias: FID )
    Shape ( type: esriFieldTypeGeometry , alias: Shape )
    OBJECTID ( type: esriFieldTypeInteger , alias: OBJECTID )
    COUNTRY ( type: esriFieldTypeString , alias: COUNTRY , length: 50 )
    CONTINENT ( type: esriFieldTypeString , alias: CONTINENT , length: 13 )
    ISO3A ( type: esriFieldTypeString , alias: ISO3A , length: 5 )
    ISO2 ( type: esriFieldTypeString , alias: ISO2 , length: 5 )
    Shape_Leng ( type: esriFieldTypeDouble , alias: Shape_Leng )
    Shape_Area ( type: esriFieldTypeDouble , alias: Shape_Area )

Supported Operations:   Query   Generate Renderer   Return Updates