Description
Class hierarchy
esri.layers.Layer
Subclasses
DynamicMapServiceLayer GraphicsLayer TiledMapServiceLayer Properties
| id |
String
|
ID assigned to the layer. If not assigned, esri.Map assigns value. By default, the ID of the layer is "layer" followed by a number. The ID can be user defined only in the layer constructor. |
| loaded |
Boolean
|
When the layer is loaded, the value becomes "true", and layer properties can be accessed. The onLoad event is also fired. |
| opacity |
Number
|
Opacity or transparency of layer. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency. |
| url |
String
|
URL to the ArcGIS Server REST resource that represents a map service. To obtain the URL, use Services Directory. An example URL for the Street Map service on ArcGIS Online is: http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer. |
| visible |
Boolean
|
Visibility of the layer. |
Methods
| hide() |
none
|
Sets the visibility of the layer to "false". The layer is not removed, but it is hidden from view. |
| setOpacity(opacity) |
none
|
Sets the opacity of the layer. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency. |
| show() |
none
|
Sets the visibility of the layer to "true". |
Events
Properties Detail
ID assigned to the layer. If not assigned, esri.Map assigns value. By default, the ID of the layer is "layer" followed by a number. The ID can be user defined only in the layer constructor.
Code snippets:
- Setting the layer ID in the layer constructor.
population = new esri.layers.ArcGISDynamicMapServiceLayer("http://myserver/arcgis/rest/population/MapServer/Layers", {id:"population"});
- Setting the layer ID after a layer is initialized.
population.id = "population";
- Retrieving the layer ID.
function getMapLayers() {
for (var j=0, jl=myMap.layerIds.length; j<jl; j++) {
var currentLayer = myMap.getLayer(myMap.layerIds[j]);
alert("id: " + currentLayer.id);
}
}
When the layer is loaded, the value becomes "true", and layer properties can be accessed. The
onLoad event is also fired.
Known values: true | false
Opacity or transparency of layer. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency.
Known values: 0.0 - 1.0
Default value: 1.0
Visibility of the layer.
Known values: true | false
Default value: true
Methods Detail
Sets the visibility of the layer to "false". The layer is not removed, but it is hidden from view.
Return value: none
Sets the opacity of the layer. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency.
Return value: none
Input Parameters:
|
<Number> opacity |
Required |
Opacity value. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency. |
Sets the visibility of the layer to "true".
Return value: none
Events Detail
Fires when there is a problem retrieving a layer. (As of v1.3)
Arguments:
Fires after layer properties for the layer are successfully populated. This event must be successful before the layer can be added to the map.
Arguments:
|
<Layer> layer
|
The loaded layer.
|
Code snippets:
In Internet Explorer, due to resource caching, the onLoad event is fired as soon as the layer is constructed. Consequently you should check whether the layer's loaded property is true before registering a listener for the onLoad event:
function init() {
//setting initial extent in constructor
var map = new esri.Map("mapDiv", { extent: new esri.geometry.Extent(...) });
//or use set extent method
var map = new esri.Map("mapDiv");
map.setExtent(new esri.geometry.Extent(...));
//add first layer
map.addLayer(...);
}
Fires when the layer opacity has been changed, and returns the opacity value.
Arguments:
|
<Number> opacity
|
Opacity or transparency of layer. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency.
|
onVisibilityChange(visbility)
Fires when the layer visibilty has been changed, and returns the new visibility.
Arguments:
|
<Boolean> visbility
|
Determines whether the layer is visible on the map.
|