2

I have to migrate to esri js api 3.2 instead of 3.6 since 3.2 uses dojo 1.7 , what are the pros n cros.If change the code which is written in 3.6 to 3.2 i.e api reference then my code breaks , any suggestion.

Below is the code if i point to 3.2 esri javascript api it breaks.

<!DOCTYPE html>
<html> 
  <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10"> 
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples 
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>FeatureLayer On Demand</title> 

    <link rel="stylesheet" href="http://js.arcgis.com/3.6/js/dojo/dijit/themes/claro/claro.css"> 
    <link rel="stylesheet" href="http://js.arcgis.com/3.6/js/esri/css/esri.css">
    <style>
      html, body, #mapDiv {
        padding:0;
        margin:0;
        height:100%;
      }
    </style>
    <script src="http://js.arcgis.com/3.6/"></script> 
    <script> 
      var map;
      require(["dojo/on", "esri/map", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/InfoTemplate", "esri/layers/FeatureLayer",
               "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "dojo/_base/Color", "esri/graphic",
               "dojo/parser", "dojo/domReady!"
      ], function(
        on,Map, ArcGISDynamicMapServiceLayer, InfoTemplate, FeatureLayer, SimpleFillSymbol, SimpleLineSymbol, Color, Graphic,  
        parser
      ) {
        parser.parse();

        var initExtent = new esri.geometry.Extent({"xmin":-21744805.806561172,"ymin":-4911537.689490959,"xmax":3302079.6219187006,"ymax":13090911.21222895,"spatialReference":{"wkid":102100}});

        map = new Map("mapDiv", { 
          extent: initExtent        
        });

        var WorldCountries = new ArcGISDynamicMapServiceLayer("http://10.97.43.4:6080/arcgis/rest/services/POC/World_Countries_ESRI_WGS84_Generaliased2/MapServer");
        WorldCountries.setDisableClientCaching(true);
        WorldCountries.setOpacity(0.75);

        map.addLayer(WorldCountries);
        showCountries();
        map.on("load", initOperationalLayer);

        function initOperationalLayer() {
          var featureLayer = new FeatureLayer("http://10.97.43.4:6080/arcgis/rest/services/POC/World_Countries_ESRI_WGS84_Generaliased2/MapServer/0",{
            mode: esri.layers.FeatureLayer.MODE_SELECTION,
          outFields: ["*"],
          opacity: 0.75
          });

          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]));
          featureLayer.setSelectionSymbol(sfs); 

          map.addLayer(featureLayer);
          map.infoWindow.resize(250,350);

          on(map,"click", function(evt){
                map.graphics.clear();

                var query = new esri.tasks.Query();
                query.geometry = evt.mapPoint;
                featureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW, function (features){
                    map.infoWindow.setTitle("Country Information");
                    map.infoWindow.setContent("Country Name: " + features[0].attributes.COUNTRY);
                    map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
                });
            });
        }


      });

      function showCountries(){
            var queryTask = new esri.tasks.QueryTask("http://10.97.43.4:6080/arcgis/rest/services/POC/World_Countries_ESRI_WGS84_Generaliased2/MapServer/0");
            //build query filter
                console.log(" showCountries");
                        var query = new esri.tasks.Query();
                        query.returnGeometry = true;
                        query.where = "COUNTRY IN ('India','Brazil','Italy','Australia','France','Libya','Russian Federation','Ukraine','United States','Canada')";
                        infoTemplate = new esri.InfoTemplate("Alert", "Alert for Re-insurance");
                        console.log(" infoTemplate "+infoTemplate);
                        dojo.connect(queryTask, "onComplete", function(featureSet) {
                                try{
                                    console.log(" query complete");
                                    var symbol0 = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 0, 0, 0.9]));
                                    dojo.forEach(featureSet.features,function(feature){
                                        //alert('feature'+feature);
                                        var graphic = feature;
                                        graphic.setSymbol(symbol0);
                                        //alert("infoTemplate"+infoTemplate);
                                        graphic.setInfoTemplate(infoTemplate);
                                        //alert("graphic"+graphic);
                                        //alert("map.graphics"+map.graphics);
                                        map.graphics.add(graphic);
                                    });
                            }catch(e){
                              alert("e"+e);
                            }
                        });
      queryTask.execute(query);
      }
    </script> 
  </head> 
  <body class="claro"> 
    <div id="mapDiv">
    </div>
  </body> 
</html>
3

The AMD coding style was introduced in the 3.5 API, so the "require" section will have to be rewritten to the legacy style. You'll have to use the legacy style for all the events (onClick vs click, etc), also.

1
  • thank you but other wise from functionality point of view like behaviour of feature layer will there be any majore difference
    – Anil
    Sep 13 '13 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.