arcgis for flex DrawTool

我真不是我 2013-05-20 05:02:40
flex代码如下,我想获取我画的图的对象,不知哪位大神可以指点指点。
比如我在上面画了个MAPPOINT图像,我该怎么获取到这个MAPPOINT相关的对象呢?

代码如下:<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags"
pageTitle="Using the DrawTool">

<s:layout>
<s:VerticalLayout paddingBottom="6"/>
</s:layout>

<fx:Style>
@namespace mx "library://ns.adobe.com/flex/mx";
mx|ToolTip
{
font-size: 14;
}
</fx:Style>

<fx:Script>
<![CDATA[
import com.esri.ags.events.DrawEvent;

import mx.events.ItemClickEvent;

import spark.events.IndexChangeEvent;

protected function tbb_itemClickHandler(event:ItemClickEvent):void
{
if (tbb.selectedIndex < 0)
{
// when toggling a tool off, deactivate it
myDrawTool.deactivate();
}
else
{
switch (event.item.label)
{
case "MAPPOINT":
{
myDrawTool.activate(DrawTool.MAPPOINT);
break;
}
/* case "MULTIPOINT":
myDrawTool.activate(DrawTool.MULTIPOINT);
break; */
/* case "Single Line":
myDrawTool.activate(DrawTool.LINE);
break; */
case "POLYLINE":
{
myDrawTool.activate(DrawTool.POLYLINE);
break;
}
case "FREEHAND_POLYLINE":
{
myDrawTool.activate(DrawTool.FREEHAND_POLYLINE);
break;
}
case "POLYGON":
{
myDrawTool.activate(DrawTool.POLYGON);
break;
}
case "FREEHAND_POLYGON":
{
myDrawTool.activate(DrawTool.FREEHAND_POLYGON);
break;
}
case "EXTENT":
{
myDrawTool.activate(DrawTool.EXTENT);
break;
}
case "CIRCLE":
{
myDrawTool.activate(DrawTool.CIRCLE);
break;
}
case "ELLIPSE":
{
myDrawTool.activate(DrawTool.ELLIPSE);
break;
}
}
}
}

protected function drawTool_drawEndHandler(event:DrawEvent):void
{
// reset after finished drawing a feature
myDrawTool.deactivate();
tbb.selectedIndex = -1;
}
]]>
</fx:Script>

<fx:Declarations>
<!-- Symbol for all point shapes -->
<esri:SimpleMarkerSymbol id="sms"
color="0x00FF00"
size="12"
style="square"/>

<!-- Symbol for all line shapes -->
<esri:SimpleLineSymbol id="sls"
width="3"
color="0x00FF00"/>

<!-- Symbol for all polygon shapes -->
<esri:SimpleFillSymbol id="sfs"
color="0xFFFFFF"
style="diagonalcross">
<esri:outline>
<esri:SimpleLineSymbol width="2" color="0x00FF00"/>
</esri:outline>
</esri:SimpleFillSymbol>

<esri:DrawTool id="myDrawTool"
drawEnd="drawTool_drawEndHandler(event)"
fillSymbol="{sfs}"
graphicsLayer="{myGraphicsLayer}"
lineSymbol="{sls}"
map="{myMap}"
markerSymbol="{sms}"/>
</fx:Declarations>

<s:controlBarLayout>
<s:HorizontalLayout horizontalAlign="center"
paddingBottom="7"
paddingTop="7"/>
</s:controlBarLayout>
<s:controlBarContent>
<mx:ToggleButtonBar id="tbb"
itemClick="tbb_itemClickHandler(event)"
labelField="null"
selectedIndex="-1"
toggleOnClick="true">
<fx:Object icon="@Embed(source='assets/i_draw_point.png')" label="MAPPOINT"/>
<fx:Object icon="@Embed(source='assets/i_draw_line.png')" label="POLYLINE"/>
<fx:Object icon="@Embed(source='assets/i_draw_freeline.png')" label="FREEHAND_POLYLINE"/>
<fx:Object icon="@Embed(source='assets/i_draw_poly.png')" label="POLYGON"/>
<fx:Object icon="@Embed(source='assets/i_draw_freepoly.png')" label="FREEHAND_POLYGON"/>
<fx:Object icon="@Embed(source='assets/i_draw_rect.png')" label="EXTENT"/>
<fx:Object icon="@Embed(source='assets/i_draw_circle.png')" label="CIRCLE"/>
<fx:Object icon="@Embed(source='assets/i_draw_ellipse.png')" label="ELLIPSE"/>
</mx:ToggleButtonBar>
</s:controlBarContent>

<esri:Map id="myMap"
level="3"
wrapAround180="true">
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/>
<esri:GraphicsLayer id="myGraphicsLayer"/>
</esri:Map>

<s:Label width="100%" text="The DrawTool can be used to draw new features which can then either be used as input for a task or saved as new features in a feature service (using FeatureLayer.applyEdits)."/>
<s:Label width="100%" text="Use the EditTool to edit existing geometries. The Editor component combines both these tools for an easy user experience."/>

</s:Application>
...全文
168 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
y541397839 2013-05-29
  • 打赏
  • 举报
回复
我用过drawtool在地图上画直线或者路网并计算距离

4,328

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计 Flex
社区管理员
  • Flex
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧