AnsweredAssumed Answered

JSON Web Service appear on Map with point graphics , when click on point show the data into info temple.

Question asked by anuj_arcgis on Apr 22, 2018
Latest reply on Apr 24, 2018 by anuj_arcgis

I have JSON Web Service which need to show on Dynamic Map with point Graphics so, when i click on point graphics which are appear on Map it should be show data of Json Service into Info template. I have define all thing in code as per my knowledge and i can see the json data at the time of debugging but when i call it i get error length property . am sharing code any one help predicated.

 

My code:-

 

 <script src="https://js.arcgis.com/3.23/"></script> 
     
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> 
     
<script>    var dojoConfig = {      parseOnLoad: true    };  </script> 
  
<script>     
var map; var mis_rec = [];    
var mis_recPoly = []; var gis_rec = []; var attributes = [],point,pointData;      

  require(["esri/map",   
      "esri/layers/ArcGISDynamicMapServiceLayer",
         "esri/layers/ImageParameters", 
           "esri/InfoTemplate",  
            "dojo/dom",  
             "dojo/on",     
             "dojo/dom-class",  
             "dojo/_base/json",        
             "esri/config",      
           "dojo/_base/lang",         
           "esri/request",  
         "esri/geometry/Point",
"esri/symbols/SimpleMarkerSymbol",
         "esri/graphic", "esri/layers/GraphicsLayer",
            "dojo/domReady!" ],
function (Map, ArcGISDynamicMapServiceLayer,
               ImageParameters,InfoTemplate, dom,
                  on, domClass, dojoJson, esriConfig, 
          esriRequestlang,esriRequest,Point, SimpleMarkerSymbol,
           Grahpic, GraphicsLayer) { 
  esriConfig.defaults.io.corsEnabledServers.push("ncog.gov.in");   
      map = new Map("mapDiv", {  
        sliderOrientation : "horizontal" 
        });  
          var imageParameters = new ImageParameters();
         imageParameters.format = "jpeg"; //set the image type to PNG24, note default is PNG8.  
        //Takes a URL to a non cached map service.
         var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("
http://10.1.31.13/arcgis/rest/services/Thematic_Atlas/DVA/MapServer",
            { 
             "opacity" : 1, 
          "imageParameters" : imageParameters
         });   
          var polygraphlayer = new GraphicsLayer(); 
          map.addLayers([dynamicMapServiceLayer,polygraphlayer]);
      dojo.connect(map,"onLoad",_ajaxcall);
               function _ajaxcall(gis_rec) { 
        //document.getElementById("bodyloadimg").style.display = "block"; 
        $.ajax({
             type: 'GET',   
          url: "
https://ncog.gov.in/JSON_webservice/get_food_data?code=7654",   
          crossDomain: true, 
            success: function (dat) {
                 mis_rec = []; 
              mis_recPoly = [];       
                      point = new Point();
                  pointData = dat.point;     
                    for (var j = 0; j < pointData.length; j++) {   
                     var attributes = [];     
                for (var i = 0; i < pointData[j].children.length; i++) {    
                     var chk = pointData[j].children[1].nodeName + "=" + pointData[j].children[1].innerHTML;                        
                        attributes[pointData[j].children[i].nodeName] = pointData[j].children[i].innerHTML; 
                    }
                     mis_rec.push(attributes); 
                }                // var polygonData = dat.getElementsByTagName('polygon');
                   gis_mis1(mis_rec);  
                 },
             error: function (err) { 
                //document.getElementById("bodyloadimg").style.display = "none";    
             alert(err.statusText);             }
         });      }   
  function gis_mis1(mis_rec) {
               clearGraphics();
             for (var i = 0; i < mis_rec.length; i++) {
                 if (mis_rec[i].log && mis_rec[i].lat) {
                     var pt = new Point(Number(mis_rec[i].log), Number(mis_rec[i].lat), new SpatialReference({ wkid: 4326 }));   
                 // if (mis_rec[i][name]>0) {  
                       var markersymbol = new PictureMarkerSymbol('images/hos.png', 18, 22); 
                       var attr = mis_rec[i];
             //{ "Activity": activity.activityName, "Activity Code": activity.activityCode }; 
                    var content = '
<table>'; 
                    content += "
<tr><td><b>District Id</td></b>" + "<td><b>: </b></td><td> ${dist_id}</td></tr>"; 
                    content += "
<tr><td><b>Email Nodal</td></b>" + "<td><b>: </b></td><td> ${email_nodal}</td></tr>"; 
                    content += "
<tr><td><b>State Id</td></b>" + "<td><b>: </b></td><td> ${st_id}</td></tr>";  
                   content += "
<tr><td><b>Total Land</td></b>" + "<td><b>: </b></td><td> ${total_land}</td></tr>"; 
                    content += "
<tr><td><b>Industrial Name</td></b>" + "<td><b>: </b></td><td> ${industrial_name}</td></tr>";
                     content += "
<tr><td><b>Land Area</td></b>" + "<td><b>: </b></td><td> ${land_area}</td></tr>";  
                   content += "
<tr><td><b>Nodal Name</td></b>" + "<td><b>: </b></td><td> ${name_nodal}</td></tr>"; 
                    content += "
<tr><td><b>EHR</td></b>" + "<td><b>: </b></td><td> ${EHR}</td></tr>";     
                content += "
<tr><td><b>Id</td></b>" + "<td><b>: </b></td><td> ${id}</td></tr>";       
              content += "
<tr><td><b>Category</td></b>" + "<td><b>: </b></td><td> ${category}</td></tr>";  
                   content += '
</table>';                    
         var infoTemplate = new InfoTemplate('Land Info', content);   
                  polygraphlayer.add(new Graphic(pt, markersymbol, attr, infoTemplate)); 
                //}        
      }             }      }        
  var gl = new GraphicsLayer({ id: "st_id" }); 
          map.addLayer(gl); 

Outcomes