Original User: schlomm.darmann@googlemail.comOriginal Date: 2013-09-23T12:19:12-0600Hello,I've recently started with the developement of a small webmap using Java script.For now I just concentrate on some basic features like adding a scalebar and an overview map.I've search for some examples for scalebar and overviewmap and put them together:
<link rel="stylesheet" href="http://js.arcgis.com/3.6/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.6/js/esri/css/esri.css">
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
#map{padding:0;}
</style>
<script src="http://js.arcgis.com/3.6/"></script>
<script>
var map;
require([
"esri/map", "esri/dijit/Scalebar", "esri/dijit/OverviewMap",
"dojo/parser",
"dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!",
], function(
Map, Scalebar, OverviewMap,
parser
) {
parser.parse();
map = new Map("map", {
basemap: "topo",
center: [-116.093, 34.218],
zoom: 7
});
var scalebar = new Scalebar({
map: map,
// "dual" displays both miles and kilmometers
// "english" is the default, which displays miles
// use "metric" for kilometers
scalebarUnit: "dual"
});
var overviewMapDijit = new OverviewMap({
map: map,
visible: true
});
overviewMapDijit.startup();
});
</script>
</head>
Now I want to replace the basemap with a dynamicMapServicelayer but it doesn't work. The code for using a dynamicMapService is the following...I've tried out so many combination, but with no success. <script src="http://js.arcgis.com/3.6/"></script>
<script>
dojo.require("esri.map");
var map;
function init() {
map = new esri.Map("mapDiv", {
// sliderOrientation: "horizontal"
});
var imageParameters = new esri.layers.ImageParameters();
imageParameters.format = "jpeg"; //set the image type to PNG24, note default is PNG8.
//Takes a URL to a non cached map service.
var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer", {
"opacity":1,
"imageParameters":imageParameters
});
map.addLayer(dynamicMapServiceLayer);
}
dojo.ready(init);
</script>
It would be really nice, if somebody would help me. In addition I have another question: For which purpose I need the "function init()" and "dojo.ready(init);"? I've read the documentation, but this didn't help me.Thanks in advance,Dominik