Select to view content in your preferred language

How do I switch BaseLayers or why does a WMSLayer prevent my other layers to show?

606
2
02-21-2013 05:17 PM
stevemclaughlin
Occasional Contributor
I've got a WMSLayer as the first layer in a map, and I'm adding a ArcGISTiledMapServiceLayer to the map, but whereever I put it, at index 0 or index 1, it won't show???

Do I need to switch the baselayer?

here's the code:

<?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="World Imagery Map">
 <fx:Script>
  <![CDATA[
   import com.esri.ags.layers.ArcGISTiledMapServiceLayer;
   
   protected function button1_clickHandler(event:MouseEvent):void
   {
    var url:String = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer";
    var tiledMapLayer:ArcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer( url);
    mymap.addLayer(tiledMapLayer  );     
   }
  ]]>
 </fx:Script>
 <esri:Map id="mymap" wrapAround180="true">
  <esri:WMSLayer  id="amIaBug"  visible="false" />
  <!--<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/>-->
 </esri:Map>
 <s:Button top="50" left="100" label="add Layer" click="button1_clickHandler(event)" />
</s:Application>



I have a map with a WMSLayer, when I click the button - it adds a tiledMapServiceLayer, but it doesn't show, try adding it before or after the WMSLayer and it still doesn't show.

Comment out the WMSLayer and the Tiledlayer shows fine.

How do I get it to show?
thanks,
Tags (2)
0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
Steve,

   Normally a ArcGISTiledMapServiceLayer is used as the first layer in the map so that it sets the maps LODs (levels of Display) I you are going to add an ArcGISTiledMapServiceLayer at a later point than you need to manually specify the Maps LODs and they will need to be the same (or partially the same) as the ArcGISTiledMapServiceLayer you intend to add. You also need to be concerned with the WKID of all your map layers as the ArcGISTiledMapServiceLayer  will not get re-projected to match your WMSLayer.
0 Kudos
stevemclaughlin
Occasional Contributor
Hi, I just created a blank baselayer and will load it later when I know the url.
ex:
<exri:Map id='myMap'/>
<esri:ArcGisTiledMapServiceLayer id='baselayer' />
<exri:WMSLayer url='http://myweb.com/map.cgi' />

then later in my code:
baselayer.url = 'http://server.arcgisonline.com/blah/blah/mapserver';

This seems to be working fine for me, do you see any side effects that may come up?
thanks,
steve
0 Kudos