<?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:esri="http://www.esri.com/2008/ags" pageTitle="Example - ArcGIS API for Flex connecting to a dynamic ArcGIS map service"> <esri:Map> <esri:ArcGISDynamicMapServiceLayer url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer"/> </esri:Map> </s:Application>
Solved! Go to Solution.
<?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:esri="http://www.esri.com/2008/ags"
pageTitle="Example - ArcGIS API for Flex connecting to a dynamic ArcGIS map service">
<fx:Script>
<![CDATA[
import mx.controls.*;
import com.esri.ags.layers.*;
protected function button1_clickHandler(event:MouseEvent):void
{
try
{
var layer:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer");
map.addLayer(layer, 0);
Alert.show("Layer Added.");
}
catch(e:Error)
{
Alert.show(e.toString());
}
}
]]>
</fx:Script>
<esri:Map id="map" x="378" y="81" width="1002" height="590">
<!--<esri:ArcGISDynamicMapServiceLayer
url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer"/>-->
</esri:Map>
<s:Button x="133" y="169" label="Button" click="button1_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:esri="http://www.esri.com/2008/ags"
pageTitle="Example - ArcGIS API for Flex connecting to a dynamic ArcGIS map service">
<fx:Script>
<![CDATA[
import mx.controls.*;
import com.esri.ags.layers.*;
protected function button1_clickHandler(event:MouseEvent):void
{
try
{
/* var layer:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer");
map.addLayer(layer, 0);
Alert.show("Layer Added."); */
map.visible=true;
Alert.show("Layer Added.");
}
catch(e:Error)
{
Alert.show(e.toString());
}
}
]]>
</fx:Script>
<esri:Map id="map" x="378" y="81" width="1002" height="590" visible="false">
<esri:ArcGISDynamicMapServiceLayer
url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer"/>
</esri:Map>
<s:Button x="133" y="169" label="Button" click="button1_clickHandler(event)"/>
</s:Application>