現在、マップは、見つかった各結果のグラフィックをデータグリッドに追加します。しかし、データグリッドで選択したグラフィックのみを追加し、選択した機能に範囲 (ズーム) を設定したいと考えています。誰もこれを行う方法を知っていますか? 今、私は次のようにしています:
function showResults(results) {
var markerSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE,
10,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([0,255,255]), 2),
new dojo.Color([0,255,0,0])
);
var lineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([0,255,255]),
4
);
var polygonSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([0,255,255]), 4),
new dojo.Color([0,255,255,0])
);
map.graphics.clear();
var dataForGrid = [];
dojo.forEach(results, function(result) {
var graphic = result.feature;
dataForGrid.push([ result.foundFieldName, result.value]);
switch (graphic.geometry.type) {
case "point":
graphic.setSymbol(markerSymbol);
break;
case "polyline":
graphic.setSymbol(lineSymbol);
break;
case "polygon":
graphic.setSymbol(polygonSymbol);
break;
}
map.graphics.add(graphic);
});
var data = {
items: dataForGrid
};
var store = new dojo.data.ItemFileReadStore({
data: data
});
grid.setStore(store);
}
function onRowClickHandler(evt){
var clickedTaxLotId = grid.getItem(evt.rowIndex).POINT_NAME;
var selectedTaxLot;
dojo.forEach(map.graphics.graphics,function(graphic){
if((graphic.attributes) && graphic.attributes.POINT_NAME === clickedTaxLotId){
selectedTaxLot = graphic;
return;
}
});
if (selectedTaxLot.geometry.declaredClass == 'esri.geometry.Point' ) {
var PointExtent = new esri.geometry.Extent(); PointExtent.xmin = selectedTaxLot.geometry.x - 100; //I'm using State Plane Feet, so
that's 100 out from my point PointExtent.ymin =
selectedTaxLot.geometry.y - 100; PointExtent.xmax =
selectedTaxLot.geometry.x + 100; PointExtent.ymax =
selectedTaxLot.geometry.y + 100; map.setExtent(PointExtent);
} else if (selectedTaxLot.geometry.declaredClass == 'esri.geometry.Polyline' ) {
var taxLotExtent = selectedTaxLot.geometry.getExtent();
map.setExtent(taxLotExtent);
} else if (selectedTaxLot.geometry.declaredClass == 'esri.geometry.Polygon' ) {
var taxLotExtent = selectedTaxLot.geometry.getExtent();
map.setExtent(taxLotExtent);
}
}