Select to view content in your preferred language

Combine basemap layers

3063
23
11-22-2010 06:40 AM
JustinFultz
Regular Contributor
I am trying to combine a imagery layer and a boundaries layer, and I don't want the boundaries layer to show up as an option on the base layers selection bar.

Any ideas?
Tags (2)
0 Kudos
23 Replies
JustinFultz
Regular Contributor
With that easy of an answer, my question now seems a little dumb.  Sorry for my complete lack of knowledge regarding this tool.  I'm slowly learning though.

Thanks for all of your help!  I'm sure you'll hear from me again soon.
0 Kudos
AYounas
Occasional Contributor
Hi Robert,

I tried your code below but on the line "addLayerToMap(configData.basemaps, false);" it says only one argument requires and if I use one argument it wont do anything and places comes in the "more.." list. Any suggestion to fix this please? (I require to join two basemap layers exactly as mentioned by you.)

Thanking you in advance,

Adi

Justin,

   Here is what needs to be done for FlexViewer 2.x

MapManager.mxml is the only file to be changed and two functions need to be altered.

This code is developed for combining two basemap layers called "Places" and "Aerial":
            //basemap menu clicked
            private function basemapMenuClicked(event:AppEvent):void
            {
                var id:String = event.data as String;
                var configBasemaps:Array = configData.basemaps;

                if (id)
                {
     var BaseMapChoosen:String = "";
     var lyrNames:Layer = map.getLayer("Places");
                    for (var i:Number = 0; i < configBasemaps.length; i++)
                    {
                        var label:String = configBasemaps.label;
                        var lyr:Layer = map.getLayer(label);
                        if (lyr != null)
                        {
                            if (configBasemaps.id == id)
                            {
                                lyr.visible = true;
        BaseMapChoosen = configBasemaps.label
                            }
                            else
                            {
                                lyr.visible = false;
                            }
       if(lyrNames){
        if(BaseMapChoosen == "Aerial")
        {
         lyrNames.visible = true; 
        }else{
         lyrNames.visible = false;
        }
       }
                        }
                    }
                }
            }

            private function configBasemaps():void
            {
                var i:int = 0;
                for (i = 0; i < configData.basemaps.length; i++)
                {
                    if (i == configData.basemaps.length - 1)
                    {
                        map.addEventListener(MapEvent.LAYER_ADD, layerloadComplete);
                    }
                    addLayerToMap(configData.basemaps, false);
                }
    // remove the excluded basemaps
    var shownBaseMaps:Array = configData.basemaps.slice();
    for (var n:Number = 0; n < shownBaseMaps.length; n++)
    {
     if (shownBaseMaps.label == "Places")
      shownBaseMaps.splice(n, 1);
    }
    configData.basemaps = shownBaseMaps;
            }
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Adi,

   All of this code was for older versions of the viewer... In the Flex Viewer now all you have to do to combine two base maps is to give them identical labels in the main config.

Using basemaps and operational layers <basemaps> - List of map services used as a base map in the Viewer. Only one base map can be visible at a time, but a base map can consist of more than one layer. To create hybrid base map, set the name property to be the same on all the layers in the basemaps group that should make up the hybrid base map. When multiple map services are listed in <basemaps>, the  Map Switcher widget can be used to enable end users to switch between them. <basemaps> has one child tag that can be repeated multiple times:

  • <layer> - This is a map service displayed as a layer in the Viewer. See  Layer tag topic for information on its attributes.



from: http://help.arcgis.com/en/webapps/flexviewer/help/index.html#/Main_configuration_file/01m30000001800...
0 Kudos
AYounas
Occasional Contributor
Adi,

   All of this code was for older versions of the viewer... In the Flex Viewer now all you have to do to combine two base maps is to give them identical labels in the main config.



from: http://help.arcgis.com/en/webapps/flexviewer/help/index.html#/Main_configuration_file/01m30000001800...


Hi Robert,

Thanks alot for your detailed answer, actually it was my ignorance, I tried this method which didnt work then I searched on forum and found your code so came up with a question sent earlier. Problem was, order of layers were not right.

One more thing please, I need to replace "more..." button to toggle on and off my one operational layer since I have only one there is no need for more... in my case. Any suggestions on that, please?
0 Kudos