I created a custom widget that works well developed from my pc but when I push it to the server it fails--. I know there are potential proxy/php work arounds but I think it may be useful to others so if I could fix it and share it like the other widgets. Here is the source code.
<?xml version="1.0" encoding="utf-8"?> <!-- /////////////////////////////////////////////////////////////////////////// // Copyright (c) 2010-2011 Esri. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License.
//this function called when the widget's configuration is loaded private function init():void { if (configXML) // checking for valid content in the configuration file { lbl.text = configXML.content || getDefaultString("helloContent"); } } private function helloWorld_openHandler (event:Event):void { map.addEventListener(MapMouseEvent.MAP_CLICK,mapClicked); }
private function mapClicked (event:MapMouseEvent) :void { var content:Object = {}; content.wm = event.mapPoint; content.ll = WebMercatorUtil.webMercatorToGeographic(event.mapPoint) as MapPoint; username.text= ""+content.ll.y; emailaddress.text= ""+content.ll.x; userRequest.send();
} protected function helloWorld_closedHandler(event:Event):void { map.removeEventListener(MapMouseEvent.MAP_CLICK,mapClicked); } public function handleLink():void { var newLink:URLRequest = new URLRequest(url.text); navigateToURL(newLink,"_blank"); } ]]> </fx:Script> <fx:Declarations> <s:HTTPService id="userRequest" url="http://www.ngdc.noaa.gov/geomag-web/calculators/calculateDeclination.xml" useProxy="false" method="GET"> <mx:request xmlns=""> <lat1>{username.text}</lat1> <lon1>{emailaddress.text}</lon1> <resultFormat>xml</resultFormat> </mx:request> </s:HTTPService> </fx:Declarations> <viewer:WidgetTemplate id="helloWorld" width="400" height="300" open="helloWorld_openHandler(event)" closed="helloWorld_closedHandler(event)"> <viewer:layout> <s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/> </viewer:layout>
checked with the admin at noaa, and said that they are not yet ready to add a cross domain for the subdomain that houses the magnetic data, so php is the way to go.