var fullExtent; for (var i = 0, il = results.features.length; i < il; i++) { fullExtent = results.features.geometry.getExtent(); fullExtent.union(fullExtent); }
var Extent = esri.graphicsExtent(FeatureSet.features);
I need to zoom to ALL the features returned, not just the 1st feature. I tried to modify your sample but was not getting anywhere.
function showResults(results) { //This function is run when the query has finished. //It zooms the map to the extent of the first feature returned by the query. var result = results.features[0]; var extent = result.geometry.getExtent().expand(5.0);
var fullExtent; for each result in results: thisExtent = result.geometry.getExtent(); fullExtent.union(fullExtent);
function showResults(results) { var result = results.features[0]; var extent = result.geometry.getExtent().expand(5.0); map.setExtent(esri.geometry.geographicToWebMercator(extent)); }
i can't seem to find a simple example of passing a variable to the query task to pan and zoom
//Define a new Query and QueryTask queryTask = new esri.tasks.QueryTask(UrlToYourLayer); query = new esri.tasks.Query(); query.returnGeometry = true; query.outFields = ["field1","field2"]; //The query's where clause will be attribute query to find the feature query.where = "'OBJECTID = 123'"; //Run the query. Its results are returned in the function showResults queryTask.execute(query,showResults); //results is an array of any found features. Assuming you only want the first feature: function showResults(results) { var result = results[0]; var extent = result.geometry.getExtent().expand(5.0); map.setExtent(extent); }
i have passed the variable to javascript but am unable to see how to pass the variable to the map to zoom to the feature(QueryTask?)
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.