control zoom level when using query url parameter

552
1
05-31-2020 04:00 AM
SPNIOrganization
Occasional Contributor

Hi,

I have an app made using web appbuilder developer edition V 2.14

I am using query url parameter to focus on a feature. The query works well, but - the zoom level is too close.

I changed the zoom level inside the "MapUrlParamsHandlerfile" in the jimu.js folder:

query.maxAllowableOffset = 0.00001;
layer.layerObject.queryFeatures(query).then(function(featureSet){
var features = featureSet.features;
if(features.length === 0){
console.log('No result from query URL parameter.');
return;
}
if(layer.layerObject.geometryType === 'esriGeometryPoint' && features.length === 1){
map.setExtent(scaleUtils.getExtentForScale(map, 100000));//same scale with search dijit
map.centerAt(features[0].geometry);
}else{
var resultExtent = jimuUtils.graphicsExtent(features);
map.setExtent(resultExtent);
}

showSelections(map, layer, features);
}, function(err){
console.error(err);
});
}

 

but it does not effect the query result zoom level.

I guess this is not the right place to specify the zoom level I want.

so, where is the right place??

thank you!

Dikla.

0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus

Dikla,

   So is your feature that is queried a point feature? Because the line you have with the red text will only come into effect if the returned feature is a point type. If it is not a point then it will get the features extent in the else portion of the if statement. to control that you need to expand the extent by some factor.

}else{
  var resultExtent = jimuUtils.graphicsExtent(features);
  map.setExtent(resultExtent.expand(1.5)) //this means expand the extent by 50%;
}
0 Kudos