//create Identify and Clear buttons to start/stop identifying features function createButtons(){ toolBar = new esri.toolbars.Draw(map); button1 = new dijit.form.Button({ id: "identifyButton", showLabel: true, checked: false, label: "Identify", onClick: function(){ toolBar.activate(esri.toolbars.Draw.POINT); dojo.connect(featureLayer, "onClick", populateGrid) }, }).placeAt(dojo.byId("buttons")); button2 = new dijit.form.Button({ id: "clearButton", showLabel: true, checked: false, label: "Clear", onClick: function(){ clear(); }, }).placeAt(dojo.byId("buttons")); } //populate grid in left pane function populateGrid(evt){ var query = new esri.tasks.Query(); query.geometry = pointToExtent(map, evt.mapPoint, 4); //select features based on map click featureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW, function(features, selectionMethod){ var items = dojo.map(features,function(feature){ return feature.attributes; }); var data = { identifier:"objectid", items:items}; //add attributes to grid store = new dojo.data.ItemFileReadStore({data:data}); var grid = dijit.byId("grid"); grid.setStore(store); }); } //retrieve extent of map click function pointToExtent(map, point, toleranceInPixel) { var pixelWidth = map.extent.getWidth() / map.width; var toleraceInMapCoords = toleranceInPixel * pixelWidth; return new esri.geometry.Extent( point.x - toleraceInMapCoords, point.y - toleraceInMapCoords, point.x + toleraceInMapCoords, point.y + toleraceInMapCoords, map.spatialReference ); } //clear grid function clear(){ toolBar.deactivate(); featureLayer.clearSelection() var items = ""; var data = { identifier:"", items:items} store = new dojo.data.ItemFileReadStore({data:data}); var grid = dijit.byId('grid'); grid.setStore(store); }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.