I have my own widget in the SFV 1.3 were the user draws either a point, polyline, polygon or extent, which is used for a spatial query. This works fine.Now I've added a numeric stepper where the user may choose to make the query using a buffer around the point/polyline/polygon/extent. This works for all types except the extent.I've added a Fault handler that gives me this message:faultCode:400 faultString:'' faultDetail:'Invalid geometry type: 'esriGeometryEnvelope''Is it impossible to use the extent geometry type as an input to a buffer geometry service?If so, is there a way to "convert" the extent/envelope to a polygon?The buffer is using this geometry service: "http://sampleserver2.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"and the code looks like this:
private function itemClickHandler(event:ItemClickEvent):void
{
switch (event.index)
{
case 0:
{
setMapAction(Draw.MAPPOINT, "Sök med Punkt", drawEnd);
break;
}
case 1:
{
setMapAction(Draw.POLYLINE, "Sök med Linje", drawEnd);
break;
}
case 2:
{
setMapAction(Draw.POLYGON, "Sök med Yta", drawEnd);
break;
}
case 3:
{
setMapAction(Draw.EXTENT, "Sök med rektangel", drawEnd);
break;
}
}
}
private function drawEnd(event:DrawEvent):void
{
clear();
if (buffert.value > 0) {
var bufferParameters:BufferParameters = new BufferParameters();
bufferParameters.features = [event.graphic];
bufferParameters.distances = [buffert.value];
bufferParameters.unit = BufferParameters.UNIT_METER;
bufferParameters.bufferSpatialReference = new SpatialReference(3021);
myGeometryService.addEventListener(GeometryServiceEvent.BUFFER_COMPLETE, bufferCompleteHandler);
myGeometryService.addEventListener(FaultEvent.FAULT, bufferFaultHandler);
myGeometryService.buffer(bufferParameters);
function bufferCompleteHandler(event:GeometryServiceEvent):void
{
myGeometryService.removeEventListener(GeometryServiceEvent.BUFFER_COMPLETE, bufferCompleteHandler);
for each (var graphic:Graphic in event.graphics)
{
graphic.symbol = symbBuff;
graphicsLayer.add(graphic);
query.geometry = graphic.geometry;
queryFastighet.execute(query);
}
}
function bufferFaultHandler(event:FaultEvent):void
{
Alert.show(event.fault.message.toString());
}
}
else {
query.geometry = event.graphic.geometry;
queryFastighet.execute(query);
}
}