Hi all,
Is there a way to highlight and zoom to graphics in 4.4 ? In 3.21 i used graphicsUtils.
var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,new Color([0, 0, 0, 0.65]), 2),new Color([24, 24, 199, 0.5]));
var test = new Graphic(AOI, symbol);
var extent = graphicsUtils.graphicsExtent(GraphicsParceliden.graphics);
map.setExtent(extent, true);
Solved! Go to Solution.
Try making the following changes in your code and see if that helps. Basically I used then to execute the zoomparcel function once the query parcel task is done. And then in zoomparcel switch from result.feature to result.features.
queryparcelTask.execute(query).then(zoomparcel);
function zoomparcel(result){
var AOI = result.features;
view.goTo(AOI);
}
You can use the goTo method on the MapView to navigate to a graphic or an array of graphics.
MapView | API Reference | ArcGIS API for JavaScript 4.4
To test this functionality you can add a view.goTo(results.features) at line 258 of this sample.
Thanks Kelly! I see it in action in the sandbox you sent me but cannot replicate it with my code:
$("#execute").click(function (){
var value = $( "#searchtext" ).val();
console.log(value);
var queryparcelTask = new QueryTask({url: "http://gem.edcgov.us/arcgis/rest/services/Sheriff/Parcels/MapServer/0"});
var query = new Query();
query.returnGeometry = true;
query.where = "PRCL_ID = '" + value + "'";
queryparcelTask.execute(query, zoomparcel);
});
....
function zoomparcel(result){
var AOI = result.feature;
view.goTo(AOI);
}
here is my jsbin
I used to capture result geometries in 3.21 "feature.geometry". Not too sure if its needed or not in 4.4?
Thanks for all your help.
Try making the following changes in your code and see if that helps. Basically I used then to execute the zoomparcel function once the query parcel task is done. And then in zoomparcel switch from result.feature to result.features.
queryparcelTask.execute(query).then(zoomparcel);
function zoomparcel(result){
var AOI = result.features;
view.goTo(AOI);
}
That was it! Thank you. I need to get more familiar with the "then"
Last question, is there a way to zoom a little less, not that close to the feature?
You should be able to modify the zoom level using the scale or zoom options available on goTo. The doc for goTo has a few examples showing how this works.
What are you using to highlight the feature/graphic? I don't see that in your code.