您的位置:首页 > 其它

基于Flex访问Arcgis Server的rest API中的Geometry server 坐标转换(Project)

2013-10-28 17:16 239 查看

参考:http://dcec226:8399/arcgis/sdk/rest/index.html?mapserver.html

[plain]
view plaincopyprint?

<?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" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; protected function btnSend_clickHandler(event:MouseEvent):void { var params:URLVariables = new URLVariables(); var url:String="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project"; srv.url=url; params.inSR="4326"; params.outSR="102113"; params.geometries="{'geometryType':'esriGeometryPoint','geometries':[{'x':-117,'y':34}]}"; params.f="pjson"; srv.send(params); } private function gotResult(event:ResultEvent):void{ Alert.show(event.result as String); } private function gotError(event:FaultEvent):void{ Alert.show(event.toString()); } ]]> </fx:Script> <fx:Declarations> <mx:HTTPService id="srv" result="gotResult(event);" useProxy="false" fault="gotError(event)"/> </fx:Declarations> <s:Button id="btnSend" label="调用" click="btnSend_clickHandler(event)"/> </s:Application>
<?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" minWidth="955" minHeight="600">

<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

protected function btnSend_clickHandler(event:MouseEvent):void
{
var params:URLVariables = new URLVariables();

var url:String="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project";
srv.url=url;

params.inSR="4326";
params.outSR="102113";
params.geometries="{'geometryType':'esriGeometryPoint','geometries':[{'x':-117,'y':34}]}";
params.f="pjson";
srv.send(params);
}

private function gotResult(event:ResultEvent):void{
Alert.show(event.result as String);
}

private function gotError(event:FaultEvent):void{
Alert.show(event.toString());
}

]]>
</fx:Script>

<fx:Declarations>
<mx:HTTPService id="srv" result="gotResult(event);" useProxy="false" fault="gotError(event)"/>
</fx:Declarations>
<s:Button id="btnSend" label="调用" click="btnSend_clickHandler(event)"/>
</s:Application>

HTTPService传送参数的第二种方式

[plain]
view plaincopyprint?

<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<!--定义HttpService发送请求-->
<s:HTTPService id="service"
url="http://localhost:8080/testhttpservice/testHttpServiceServlet"
useProxy="false"
fault="service_faultHandler(event)"
result="service_resultHandler(event)">
<s:request >
<!--参数名称作标签,中间填充参数值-->
<username>{txtusername.text}</username>
<password>{txtpassword.text}</password>
</s:request>
</s:HTTPService>
</fx:Declarations>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐