Giter VIP home page Giter VIP logo

arcgis-dijit-layer-list's Introduction

LayerList Widget

Features

The LayerList widget provides list of layers that allows the toggling of layer visibility. The style can be completely changed and skinned to match your own map design.

Purpose

  • This widget is meant to be simple. It's general purpose is for the end user to toggle layer visibility.
  • A legend isn't included along side each layer. Use the legend widget for displaying information about the layers.
  • There are options to specify a node for a button and/or custom content. These nodes will allow you to do your app's configuration of the layer or put custom content, like a transperency slider, underneath the layer's title.

Known Issues

  • Toggling of Mapservice, KML and WMS sublayers outside of the widget is not supported.
  • Out of scale range for sublayers not supported.

View it live

Quickstart

var map = response.map;
    //var layers = arcgisUtils.getLayerList(response);

    myWidget = new LayerList({
      map: map,
      //layers: layers
    }, "LayerList");
    myWidget.startup();

New to Github? Get started here.

Setup

Set your dojo config to load the module.

var package_path = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'));
var dojoConfig = {
	// The locationPath logic below may look confusing but all its doing is
	// enabling us to load the api from a CDN and load local modules from the correct location.
	packages: [{
		name: "application",
		location: package_path + '/js'
	}]
};

Require module

Include the module for the LayerList.

require(["application/LayerList", ... ], function(LayerList, ... ){ ... });

Constructor

LayerList(options, srcNode);

Options (Object)

property required type value description
theme string esriLayerList CSS Class for uniquely styling the widget.
map x Map null ArcGIS JS Map
layers x Object[] null Operational Layers (Layer Example)
visible Boolean true Show the widget
removeUnderscores Boolean true Removes underscores from the layer title
subLayers Boolean true Show sublayers in the list of layers

Layers Object

This is what the layers array should look like.

layers = [
    {
        layer: LayerObject // required unless featureCollection.
        featureCollection: featureCollection, // required unless layerObject. if the layer is a feature collection, should match AGOL feature collection response and not have a layerObject.
        subLayers: true, // optional
        content: <domNode>, // optional
        button: <domNode>, // optional
        visibility: true, // optional
        id: "my_layer" // optional
    },
    {
    	...
    }
];

Properties

property type description
theme string CSS Class for uniquely styling the widget.
map Map ArcGIS JS Map
layers Array Array of layers
visible Boolean Show the widget
loaded Boolean If the widget has been loaded.
removeUnderscores Boolean

Methods

startup

startup(): Start the widget.

destroy

destroy(): Destroy the widget.

refresh

refresh(): reload all layers and properties that may have changed.

Events

load

Example

on(widget, 'load', function(evt){…})

refresh

Example

on(widget, 'refresh', function(evt){…})

toggle

Example

on(widget, 'toggle', function(evt){…})

Event Object

{
	layerIndex: Integer,
  subLayerIndex: Integer,
	visible: Boolean
}

Requirements

  • Notepad or HTML editor
  • A little background with Javascript
  • Experience with the ArcGIS Javascript API would help.

Resources

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

Contributing

Anyone and everyone is welcome to contribute.

Licensing

Copyright 2012 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's license.txt file.

[](Esri Tags: ArcGIS JavaScript API Layer LayerList Table of Contents Public) [](Esri Language: JavaScript)

arcgis-dijit-layer-list's People

Contributors

alaframboise avatar driskull avatar gcaseycupp avatar spatialbits avatar tomwayson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arcgis-dijit-layer-list's Issues

Does this work with ArcGIS Server?

Hey,
I've tinkered with this for a while today and I can't quite make out how to give the TOC the layers that it wants. My map has one ArcGISDynamicMapServiceLayer and two graphics layers. I've toyed with layer arrays, layerinfos, etc. One thing I notice is that the _createLayerNodes looks for some properties which I can find no trace of in the api docs (eg. response.layerIndex ). Is this an ArcGISOnline only dijit? If so, how much work would it be to adapt it for ArcGIS Server?

Can't find promiseList.js.

TableOfContents.js requires "esri/promiseList" (promistList.js) but I can't find that file. I'm using a locally hosted copy of the api (v3.12) but I have also tested against the CDN versions 3.12 and 3.13 with no luck.

Any thoughts what I might be missing?

WMS/KML sublayer toggle event

Event is needed to know about sublayer changes for certain layers.

If the layers get their sublayers toggled from outside of the widget, we need to know about it.

Layer visibility toggle

If the dynamic resource has group layers, when the group layer visibility is turned off, all the sublayers' of that group layer visibility is also turned off and is not restoring after turning on. This is not very handy.

Bug in IE7 - "checked" state of checkboxes not getting set at start.

Just in the off chance someone else has to develop for IE7 (I truly hope I'm the only one), the checkboxes were not being properly set to checked/unchecked when the TOC is instantiated.

Lines 286 (checked: status) and 390 (checked: subChecked) don't set the state for some reason.

Setting the state separately seemed to do the trick:
dojo.attr(checkboxNode,"checked",status);(after line 286).
and
dojo.attr(subCheckboxNode,"checked",status); (after line 392)

Group Layers are not at right level

It seems like they are always cascading instead of going back to the top level when they should.
I've played with this a bit, but haven't found the right way to fix...

I believe the fix should be around this area of code.

// place subLayers not in the root
 if (parentId !== -1) {
          subListNode = domConstruct.create("ul", {
           className: this.css.subList
           }, this._nodes[layerIndex].subNodes[parentId].subLayer);
 }

( I worked on a sample using this mapservice - http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/MapServer
here is my publicly available webmap
( http://www.arcgis.com/home/webmap/viewer.html?webmap=dd4d01ea18154183a2b0bdad32991e82 )
The 4 top level groups are 'San Diego', 'Route', 'Closest Facility' and 'Service Area'

However, Route ends up showing under San Diego, and so on..

image

Using 'new' branch w/ mapservices instead of webmaps

1 - Good news, I tested the 'new' branch in my test environment and it worked. Yeah!

2 - Not quite as good news. When testing in our real environment, we found you are using the private property _layers off the Map object, which appears to be a different object that the one returned in the public methods from the getLayer() or getLayersVisibleatScale() calls.
This is especially problematic if using TypeScript as the _layers object is unexposed in the arcgis-js-api.d.ts file which makes it completely inaccessible.

I'm not sure why there are two different objects that represent a layer/map service, and why they have different properties. (the LayerObject propery is only available on the private _layers, not on the public Layers objects.)

so three thoughts.. (although you probably have better ideas....)

  • change to using the Public Layers object returned from the public methods. (I have the basics of this working, if you want to go this route)
  • promote the _layers object to be public
  • add the LayerObject property to the Public Layers object.

Trailing comma

Trailing comma tripped up IE.

Line 294 of TableOfContents.js: className: this.css.icon + " " + this.css.settingsIcon + " " + this.css.settings,

I can commit to the dev branch if you like.

Integrating LayerLegend widget with Javascript sample viewer

Hi driskull
I was trying to integrate your layer widget with ArcGIS javascript sample viewer and it always comes up with xhr error and the application stops at one point.

Would you able to integrate your widget with sample javascript application and post it live, so that lot of users get benefited to see how they can use your widget effectively.

Error when reload the map

Hello,

I put this template into dashboard application, separate menu. First time when I'm clicking on tab with this template this working fine. If click again on menu, I have next error:

image

Modify widget behavior

Hello,
Is it possible to modify the widget so that its behaviour will be the same as WEB ADF control (esri,toc)? Particularly, when I uncheck a group layer I don't want sublayers to be unchecked (but of course, corresponding layers should be invisible). Also if I check a group layer I don't want that all its sublayers will be checked (of course a layer should be visible if all its ancestors are visible). There is one more feature that is different from esri.toc but I like it: when check a node of a layer all its ancestor became checked.
Update: when I wrote this commentary I thought that this widget is the same one as in
http://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109
But now I see that these are 2 different widgets. In example to this widget (TableOfContent) there is no hierarchy of layers and I am not sure that it supports more than one level layers structure (?). So all my questions concerned to the second widget (toc). I realize that it may be not right place to put there such questions but I suppose that they have the same author.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.