Select to view content in your preferred language

Trying to modify - Public Information Map gallery sample

872
4
08-02-2012 11:07 AM
BobPuterski
Emerging Contributor
I am trying to modify the gallery sample - Public Information Map - 2.0. I want to include a dynamic map layer in the layers.js that will always be the active layer for map click events to display attributes in an info window but not appear in the Layers Menu for turning its display on and off. (It will be totally transparent and I do not want the user to even know the layer exists.) I have figured out the transparency and active for click event part but not how to remove it from the drop down Layers Menu. I would appreciate any help to this struggling beginner.
0 Kudos
4 Replies
danbecker
Frequent Contributor
I am trying to modify the gallery sample - Public Information Map - 2.0. I want to include a dynamic map layer in the layers.js that will always be the active layer for map click events to display attributes in an info window but not appear in the Layers Menu for turning its display on and off. (It will be totally transparent and I do not want the user to even know the layer exists.) I have figured out the transparency and active for click event part but not how to remove it from the drop down Layers Menu. I would appreciate any help to this struggling beginner.


I also modified this template, and in the end, it was a huge pain, and I almost ended up redeveloping the entire app.

If you look, there's probably a function that adds all layer variables to an array, then later, another function loops over the array adding each layer to the legend widget. Just stop the layer in question from being added to the array and your done.
0 Kudos
BobPuterski
Emerging Contributor
Thanks Dan, I'll try and find those loops.
0 Kudos
StephenLead
Honored Contributor
I want to include a dynamic map layer in the layers.js that will always be the active layer for map click events to display attributes in an info window but not appear in the Layers Menu for turning its display on and off. (It will be totally transparent and I do not want the user to even know the layer exists.)


Hi Bob,

If the layer isn't being displayed, and is only being used for query purposes, then rather than adding an "invisible" layer a better method is not to add it to the Layers list.

Instead, set up a new list for "query layers", which are those which should be queried when you click on the map (whether or not they are currently visible).

Steve
0 Kudos
BobPuterski
Emerging Contributor
Thanks Steve and Dan,

Problem solved. As Dan suggested all I had to do was place a conditional around the inner part of adding the html lines to construct the menu items. Steve's solution is more logical and will be used in my next revision when I have more time to fully customize the app. I just didn't have time to figure out adding a layer without going thru the black box userconfig. and whether something else would break if it wasn't in the layers or basemap list.

Dan's solution involved:

/*------------------------------------*/
// CREATE LAYER ITEMS
/*------------------------------------*/
function configureLayers(){
. . .
in the bottom section  insert a conditional such as
   if (userConfig.layerItems.uniqueID !== 'your_map_service') {

before the

     // COMPOSE HTML LIST STRING
     html += '<li id="' + userConfig.layerItems.uniqueID . . .

and before the append

     if (userConfig.layerItems.uniqueID !== your_map_service') {
     html += '</li>';
     // APPEND HTML
     $('#layersList').append(html);
     }
0 Kudos