Hi guys, I was wondering If anyone of you know how to do this... I have a query results, I want to make zoom to that query results, I think the properly name of it is Zoom to selected features ... please if anyone knows how to do it help me By the way: In the results I told you about, I receive the X,Y, of what I'm trying to zoom. Any code for it? in JavaScript Alex,
dojo.connect(grid, "onRowClick", onRowClickHandler); function doFind() { //Set the search text to the value in the box findParams.searchText = dojo.byId("BUILDING").value; esri.show(datagrid); //shows the entire datagrid ContentPane upon selecting the "Search" button dojo.style(dojo.byId("map"), "height", "78%"); //resizes the map (center) pane to manually fit findTask.execute(findParams,showResults); } function showResults(results) { //This function works with an array of FindResult that the task returns map.graphics.clear(); var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([98,194,204]), 2), new dojo.Color([98,194,204,0.5])); //create array of attributes var items = dojo.map(results,function(result){ var graphic = result.feature; graphic.setSymbol(symbol); map.graphics.add(graphic); return result.feature.attributes; }); //Create data object to be used in store var data = { identifier: "BUILDING", //This field needs to have unique values label: "BUILDING", //Name field for display. Not pertinent to a grid but may be used elsewhere. items: items }; //Create data store and bind to grid. store = new dojo.data.ItemFileReadStore({ data:data }); var grid = dijit.byId('grid'); grid.setStore(store); //Zoom back to the initial map extent map.setExtent(initExtent); } //Zoom to the parcel when the user clicks a row function onRowClickHandler(evt){ var clickedBuilding = grid.getItem(evt.rowIndex).BUILDING; var selectedBuilding; esri.hide(datagrid); //Re-hides the entire datagrid ContentPane after selecting a row in the datagrid dojo.style(dojo.byId("map"), "height", "98%"); dojo.forEach(map.graphics.graphics,function(graphic){ if((graphic.attributes) && graphic.attributes.BUILDING === clickedBuilding){ selectedBuilding = graphic; return; } }); var BuildingExtent = selectedBuilding.geometry.getExtent(); map.setExtent(BuildingExtent); }
//get extent of graphicsLayer's array of graphics using esri.namespace, var extent = esri.graphicsExtent(map.graphics.graphics); map.setExtent(extent, true);
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.