Basemap Settings

2087
10
03-02-2016 06:59 AM
JennaWalz2
New Contributor II

Hello,

I am using a script similar to what I have posted below. Is there a way to add a reference URL to imagery?

Thanks,

Jenna

        // BASEMAP SETTINGS

        // ------------------------------------------------------------------------------------------------------------------------

        // Set baseMap layers

        BaseMapLayers: [{

            Key: "streetMap",

            ThumbnailSource: "js/library/themes/images/parcelmap.png",

            Name: "Streets",

            MapURL: "http://yourserver/arcgis/rest/services/GeneralPurpose/MapServer"

        },{

            Key: "imagery",

            ThumbnailSource: "js/library/themes/images/imagery.png",

            Name: "Imagery",

            MapURL: "http://yourserver/arcgis/rest/services/ImageryHybrid/MapServer"

        }, {

            Key: "topoMap",

            ThumbnailSource: "js/library/themes/images/imagery.png",

            Name: "Topographic",

            MapURL: "http://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer"

    }],

0 Kudos
10 Replies
TracySchloss
Frequent Contributor

I don't understand your question.  You mean add an additional parameter to this definition?  That would be 'no' as far as I can tell.

What would you use it for?  You might be able to have an event listener on selection-change if you're using the BaseMapGallery widget.

0 Kudos
JennaWalz2
New Contributor II

I would like to add a roads layer/as a reference to the imagery. For example, you will be able to see the rad names on top of the aerial images.

0 Kudos
DarinaTchountcheva
Occasional Contributor II

Jenna,

Here is a sample code of how to add roads on top of the imagery:

var map = new Map("map", {
                basemap: new Basemap({
                    layers: [
                        new BasemapLayer({ url: 'http://myserver/arcgis/rest/services/Maps/Aerials/MapServer' }),
                        new BasemapLayer({ url: 'http://myserver/arcgis/rest/services/Maps/StreetNames/MapServer' })
                    ]
                })
            });

Best regards,

Darina

JennaWalz2
New Contributor II

Is there a way to have this in the configuration file?

0 Kudos
DarinaTchountcheva
Occasional Contributor II

Part of what application is this configuration file?

0 Kudos
JennaWalz2
New Contributor II

Here is the link to the application I am trying to configure. I am looking in the config.js file and basemap settings.

http://solutions.arcgis.com/local-government/help/public-notification/ or https://github.com/Esri/land-use-public-notification

0 Kudos
DarinaTchountcheva
Occasional Contributor II

Jenna,

I am not familiar with this application, but after brief look at it, I don't think that you can configure it to have two layers in your basemap without making any code changes.

I downloaded it now, and will try it.

I will let you know if I come up with a solution.

Darina

0 Kudos
JennaWalz2
New Contributor II

Thanks!

0 Kudos
DarinaTchountcheva
Occasional Contributor II

Hi Jenna,

After looking at the code, I found a way for  you to do what you need to do with very little change.

Disclaimers:

!!! Be advised though, it is a total hack and I have not tested all the functionality to see if it breaks anything else.

!!! I suggest, you create an issue on Github for your problem, and hopefully someone will look into it, and fix it.

!!! Best scenario for you would be to create and cache a hybrid service (image with road names), which is recommended in the application documentation.

!!! If you have no control over that, then you can try my hack, but make very good notes, so when you are upgrading the application, and it breaks, you know where to look.

Here it is:

1. Order your layers this way (I am using the fact that the first layer is added on the map and always stays there, so we need this to be the imagery. Then the second layer should be the one you need displayed on the map initially, and that usually is just a street map):

// Set baseMap layers

        BaseMapLayers: [
    {

            Key: "imagery",

            ThumbnailSource: "js/library/themes/images/imagery.png",

            Name: "Imagery",

            MapURL: "http://yourserver/arcgis/rest/services/Imagery/MapServer"

        },
    {

            Key: "streetMap",

            ThumbnailSource: "js/library/themes/images/parcelmap.png",

            Name: "Streets",

            MapURL: "http://yourserver/arcgis/rest/services/GeneralPurpose/MapServer"

        }, 
    {

            Key: "imageryStreetNames",

            ThumbnailSource: "js/library/themes/images/imagery.png", //change image to some hybrid image

            Name: "Imagery",

            MapURL: "http://yourserver/arcgis/rest/services/StreetNames/MapServer"

        },
    {

            Key: "topoMap",

            ThumbnailSource: "js/library/themes/images/imagery.png",

            Name: "Topographic",

            MapURL: "http://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer"

    }],

2. Change "0" to "1" in on the commented line in baseMapsGallery.js. In this way, the imagery which was added first will be there but hidden behind the street map, which has and index of 1 instead of 0. So change the "0" to "1" to have your street map popup first:

postCreate: function () {
            var i, basemapContainer, layer,
                baseMapURL = 0,
                baseMapURLCount = 0,
                baseMapLayers = dojo.configData.BaseMapLayers;

            for (i = 0; i < baseMapLayers.length; i++) {
                if (baseMapLayers.MapURL) {
                    this.map.addLayer(this._createBaseMapLayer(baseMapLayers.MapURL, baseMapLayers.Key));
                }                 
                if (baseMapURLCount === 1) { //on this line change "0" to "1" as shown here
                    baseMapURL = i;
                }
                baseMapURLCount++;
            }
            basemapContainer = domConstruct.create("div", {}, dom.byId("esriCTParentDivContainer"));
            basemapContainer.appendChild(this.esriCTDivLayerContainer);
            this.layerList.appendChild(this._createBaseMapElement(baseMapURL, baseMapURLCount));

            if (baseMapURLCount >= 1) {
                layer = this.map.getLayer(baseMapLayers[baseMapURL].Key);
                layer.show();
            }
        },

Test it. Hope it works for you, if nothing else is possible.

Darina