Community
All Communities
Products
ArcGIS Pro
ArcGIS Survey123
ArcGIS Online
ArcGIS Enterprise
Data Management
ArcGIS Experience Builder
Geoprocessing
ArcGIS Web AppBuilder
ArcGIS Dashboards
ArcGIS Field Maps
ArcGIS StoryMaps
All Products Communities
Industries
Education
Water Resources
State & Local Government
Transportation
Gas and Pipeline
Water Utilities
Roads and Highways
Telecommunications
Natural Resources
Electric
Imagery and Remote Sensing Insights (IRIS) COP
All Industries Communities
Developers
Python
JavaScript Maps SDK
Native Maps SDKs
ArcGIS API for Python
ArcGIS Pro SDK
ArcObjects SDK
Developers - General
ArcGIS REST APIs and Services
ArcGIS Online Developers
Game Engine Maps SDKs
File Geodatabase API
All Developers Communities
Global
Comunidad Esri Colombia - Ecuador - Panamá
ArcGIS 開発者コミュニティ
Czech GIS
ArcNesia
Europe
Esri India
Americas
Asia Pacific
Comunidad GEOTEC
GeoDev Germany
ArcGIS Content - Esri Nederland
All Global Communities
All Communities
Developers
User Groups
Industries
Services
Community Resources
Global
Events
Learning
Networks
ArcGIS Topics
Products
View All Communities
ArcGIS Ideas
GIS Life
Community Resources
Community Help Documents
Community Blog
Community Feedback
Member Introductions
All Community Resources
Sign In
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Show
only
|
Search instead for
Did you mean:
Cancel
Home
:
All Communities
:
Developers
:
JavaScript Maps SDK
:
JavaScript Maps SDK Questions
:
Sample codes for Legend and TOC
Options
Subscribe to RSS Feed
Mark Topic as New
Mark Topic as Read
Float this Topic for Current User
Bookmark
Subscribe
Mute
Printer Friendly Page
Select to view content in your preferred language
Translate Now
Sample codes for Legend and TOC
Subscribe
717
1
12-10-2012 09:48 AM
by
JoseSanchez
Frequent Contributor
12-10-2012
09:48 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Hi all
I am looking for following source code samples:
how to populate a tab with the map legend
how to load a TOC in a tab allowing to check layers to make them visible/invisible
Thanks
Tags
(2)
Tags:
javascript
web_developers
Reply
0
Kudos
All Posts
Previous Topic
Next Topic
1 Reply
by
DavidMcGill
Deactivated User
12-11-2012
05:49 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
#
var initBasemap = new esri.layers.ArcGISTiledMapServiceLayer("
http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer
", { id: 'BaseMap' });
map.addLayer(initBasemap);
legendLayers.push({ layer: initBasemap, title: ' ' });
#
#
dojo.connect(map, 'onLayersAddResult', function (results) {
var legend = new esri.dijit.Legend({ map: map, layerInfos: legendLayers }, "legendDiv");
legend.startup();
});
dojo.connect(map, 'onLayersAddResult', function (results) {
dojo.forEach(legendLayers, function (layer) {
var layerName = layer.layer.id;
var checkBox = new dijit.form.CheckBox({
name: "checkBox" + layer.layer.id,
value: layer.layer.id,
checked: layer.layer.visible,
onChange: function (evt) {
var clayer = map.getLayer(this.value);
clayer.setVisibility(!clayer.visible);
this.checked = clayer.visible;
}
});
dojo.place(checkBox.domNode, dojo.byId("toggle"), "after");
var checkLabel = dojo.create('label', { 'for': checkBox.name, innerHTML: layerName }, checkBox.domNode, "after");
dojo.place("<br />", checkLabel, "after");
});
#
#
<div id="legendPane" data-dojo-type="dijit.layout.ContentPane" title="Legend">
<div id="legendDiv">
</div>
</div>
<div id="toggleDiv" data-dojo-type="dijit.layout.ContentPane" title="Layers">
Checkbox to toggle map layer visibility.<br />
<br />
<div id="toggle">
</div>
</div>
#
Reply
0
Kudos
Post Reply