Solved! Go to Solution.
Hi,
EDIT: I think that is better to use the property setMinScale(scale) and setMaxScale(scale) for your Dynamic layers. This methods are avaiable from 3.1
Hi,
EDIT: I think that is better to use the property setMinScale(scale) and setMaxScale(scale) for your Dynamic layers. This methods are avaiable from 3.1
var dynamicMapServiceLayer1 = new esri.layers.ArcGISDynamicMapServiceLayer("http://my server:6080/arcgis/rest/services/layer11/MapServer",{"opacity":0.25});
dynamicMapServiceLayer1.setVisibleLayers([0,1]);
dynamicMapServiceLayer1.maxScale = 3000.988; // confirmed this scale in RESET api
dynamicMapServiceLayer1.minScale = 1.479; // confirmed this scale in RESET api
map.addLayer(dynamicMapServiceLayer1);
var currentScale = map.getScale(); console.log('Scale: ' + currentScale);its showing different scale.
var dynamicLayerInfo = new esri.layers.DynamicLayerInfo({ "defaultVisibility":true, "id":0,"maxScale":1000000, "minScale":0, "parentLayerId":-1 });its showing some different value.
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title></title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dijit/themes/tundra/tundra.css" />
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
h3 { margin: 0 0 5px 0; border-bottom: 1px solid #444; text-align: center }
.shadow {
-moz-box-shadow: 0 0 5px #888;
-webkit-box-shadow: 0 0 5px #888;
box-shadow: 0 0 5px #888;
}
#map{ margin: 0; padding: 0; }
#feedback {
background: #fff;
color: #444;
position: absolute;
font-family: arial;
height: 40px;
left: 30px;
margin: 5px;
padding: 10px;
bottom: 30px;
text-align: center;
width: 320px;
z-index: 40;
}
.note { font-size: 80%; padding: 0 0 10px 0; }
#slider {
color: #666;
margin: 5px auto;
padding: 3px;
}
#appSliderLabel { padding: 0 0 10px 0; }
#maxLabel { display: inline-block; margin: 0 0 0 -30px;}
#minLabel { display: inline-block; margin: 0 0 0 30px;}
#breakInfo { padding: 20px 0 0 0; }
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.1"></script>
<script>
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
// one global for persistent app variables
var app = {};
function init() {
var ext, basemap, usaUrl;
ext = new esri.geometry.Extent({"xmin":-14332474,"ymin":3248843,"xmax":-8070752,"ymax":5464906,"spatialReference":{"wkid":102100}});
app.map = new esri.Map("map", {
"extent": ext,
"slider": false
});
dojo.connect(app.map, "onLoad", function() {
dojo.connect(dijit.byId("map"), "resize", app.map, app.map.resize);
dojo.connect(app.map, "onZoomEnd", updateScale);
updateScale();
});
basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer");
app.map.addLayer(basemap);
// set up a layer to show counties as a dynamic map service
// set visible layers to [2]
usaUrl = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer";
app.usaLayer = new esri.layers.ArcGISDynamicMapServiceLayer(usaUrl, {
"id": "usa",
"opacity": 0.7
});
dojo.connect(app.usaLayer, "onLoad", function() {
app.usaLayer.setVisibleLayers([2]);
app.usaLayer.maxScale = 10000000;
app.usaLayer.minScale = 20000000;
// console.log("set dyn layer infos...", infos);
});
app.map.addLayer(app.usaLayer);
}
function updateScale() {
dojo.byId("map-scale").innerHTML = dojo.number.format(parseInt(app.map.getScale()));
}
function errorHandler(err) {
console.log('Oops, error: ', err);
}
dojo.ready(init);
</script>
</head>
<body class="tundra">
<div data-dojo-type="dijit.layout.BorderContainer"
data-dojo-props="design:'headline',gutters:false"
style="width: 100%; height: 100%; margin: 0;">
<div id="map"
data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region:'center'">
<div id="feedback" class="shadow">
Map scale: <span id="map-scale">unknown</span>
</div>
</div>
</div>
</body>
</html>