AnsweredAssumed Answered

queryTask zoom to queryResult

Question asked by Goran.Tozievski on Apr 12, 2016
Latest reply on Apr 15, 2016 by Goran.Tozievski

Hi im working on application that need to show linear route(static).Im getting the route but i cant make it to zoom to routeExtent.Here is my code.

 

require([

       "dojo/dom", "dojo/on",

       "esri/tasks/query", "esri/tasks/QueryTask", "dojo/domReady!"

        ], function (dom, on, Query, QueryTask) {

 

  var params = getUrlParams();

  var kiosk = params['kiosk'];

  var cel = params['cel'];

  var lang = params['lang'];

 

            queryTask = new esri.tasks.QueryTask("http://................................................................/MapServer/0");   

 

            var query = new Query();

            query.returnGeometry = true;

            query.outFields = [

              "*"

            ];

 

  var lang = 0;

  if(location.href.indexOf("_alb") > -1)

  lang =1;

  else if (location.href.indexOf("_en") > -1)

  lang =2;

 

  if(lang == '0'){

  queryTask = new esri.tasks.QueryTask("http://................................................................/MapServer/0 ");

  }else if(lang == '1'){

  queryTask = new esri.tasks.QueryTask("http://................................................................/MapServer/0 ");

  }

  else {

  queryTask = new esri.tasks.QueryTask("http://................................................................/MapServer/0 ");

  }

function executeRoute() {

 

  var nameKiosk ;

  if(kiosk == 1){

  nameKiosk = 1;

  }

  if(kiosk == 2){

  nameKiosk = 2;

  }

 

  if(lang == 0)

  query.where = "OD = '"+nameKiosk+"' and DO = '"+ime_objekt.innerText+"'";

  else if (lang == 1)

  query.where = "OD_AL = '"+nameKiosk+"' and DO_AL = '"+ime_objekt.innerText+"'";

  else

  query.where = "OD_EN = '"+nameKiosk+"' and DO_EN = '"+ime_objekt.innerText+"'";

  queryTask.execute(query, showResults);

  return false;

            }

 

 

  function getUrlParams() {

 

 

   var paramMap = {};

   if (location.search.length == 0) {

  return paramMap;

   }

   var parts = location.search.substring(1).split("&");

 

 

   for (var i = 0; i < parts.length; i ++) {

  var component = parts[i].split("=");

  paramMap [decodeURIComponent(component[0])] = decodeURIComponent(component[1]);

   }

   return paramMap;

  }

 

 

 

            function showResults(results) {

                var resultItems = [];

                var resultCount = results.features.length;

  var symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 255, 255]), 4);

 

 

  for (var i = 0; i < resultCount; i++) {

                    var graphic = results.features[i];

                        graphic.setSymbol(symbol);

                        app.map.graphics.add(graphic);

  var stateExtent = graphic.geometry.getExtent();

  app.map.setExtent(stateExtent);

                }

                dom.byId("info").innerHTML = resultItems.join("");

                console.log(resultItems.join(""));

            }

 

        });

 

Thanks

Outcomes