模仿百度的距离测量功能(flex,arcgis)
该功能共三个文件:?
第一个文件关键代码
public static var interval:Number=0;
public static var measureGrArr:Array=[];//地图上绘制的测量线的图层
private var measureLength:MeasureLengths;
private function lengthHandler(event:MouseEvent):void{
//setMapAction(DrawTool.POLYLINE, LocaleResource.strings("iframe_label_length"), null, _compute.drawEndHandler);_compute.mapclick _compute.measureFinish
measureLength=new MeasureLengths(configData.geometryService["url"],map);
map.addEventListener(MapMouseEvent.MAP_CLICK,click);
map.addEventListener(MouseEvent.DOUBLE_CLICK,doubleclick);
map.doubleClickEnabled=true;
map.openHandCursorVisible=false;
}
//消除单击和双击使劲啊的冲突
private function click(event:MouseEvent):void{
clearInterval(interval);
interval=setInterval(measureLength.mapclick,200,event);
}
//消除单击和双击使劲啊的冲突
private function doubleclick(event:MouseEvent):void
{
clearInterval(interval);
measureLength.measureFinish(event);
}
//取测量点完毕
private function measureFinish(event:MeasureEvent):void{
//取消测量点击的双击单击事件
map.removeEventListener(MapMouseEvent.MAP_CLICK,click);
map.removeEventListener(MouseEvent.DOUBLE_CLICK,doubleclick);
}
第二个文件-自定义事件:(以文件形式上传)
第三个文件-测量距离工具类:(以文件形式上传)
付效果图:
?
?