Select to view content in your preferred language

Zoom to query URL JS API 3,19

876
1
02-24-2017 11:22 AM
by Anonymous User
Not applicable

Hi all,

I am trying to zoom to feature when people click on url but I am having some trouble. I am using GlobalID as query item. I am not too sure why it is not picking up the globalID. Any idea?

Thanks,

Alex

 map.on("load", initOperationalLayer);


function initOperationalLayer() {



//Get URL as object
roadclosed = getParcelFromUrl(document.location.href);


//Query
var query = new Query();
var queryTaskrc = new QueryTask("http://services.arcgis.com/UHg8l1wC48WQyDSO/arcgis/rest/services/..../FeatureServer/0");
query.where = "GlobalID = '" + roadclosed + "'";
query.returnGeometry = true;
queryTaskrc.execute(query, queryCallbackrc);

}


//Make URL Query
function getParcelFromUrl(url) {
    var urlObject = urlUtils.urlToObject(url);
       if (urlObject.query && urlObject.query.roadclosed) {
            return urlObject.query.roadclosed;
            console.log(urlObject.query.roadclosed)
          } else {
            return null;
          }
  }


//Query Callback          
function queryCallbackrc(featureSet) {
      arrayUtil.forEach(featureSet.features, function (feature) {
          var thePoint = feature.geometry; 
          map.centerAndZoom(thePoint, 14);
   });
 }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Tags (1)
0 Kudos
1 Reply
by Anonymous User
Not applicable

Nevermind it seems to work as it should. but i still get weird errors.

0 Kudos