Select to view content in your preferred language

Sample to show my specific map service

737
1
09-27-2013 12:01 PM
JoseSanchez
Frequent Contributor
I am looking for a sample that shows my own map service, using the new AMD style and syntax .

Thanks


This is the code I have with the old sysntax.

dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.AccordionContainer");
dojo.require("esri.map");

var myMap;    // global variable representing the map

function init() {
 var initialExtent = new esri.geometry.Extent({"xmin":-13050590.679808607,"ymin":3848824.1306140213,"xmax":-13033430.566958608,"ymax":3863366.2752452563,"spatialReference":{"wkid":102100}});
 myMap = new esri.Map("mapDiv", {extent:initialExtent});
 var baseLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
 var opLayer1 = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/MapServer",{ opacity:0.8 });
 myMap.addLayers([baseLayer, opLayer1]);
}


dojo.addOnLoad(init);

0 Kudos
1 Reply
JasonZou
Frequent Contributor
Try:

var myMap;    // global variable representing the map

require([
  "dijit.layout.BorderContainer",
  "dijit.layout.ContentPane",
  "dijit.layout.AccordionContainer",
  "esri.map",
  "esri.geometry.Extent",
  "esri/layers/ArcGISTiledMapServiceLayer",
  "esri/layers/ArcGISDynamicMapServiceLayer",
  "dojo/domReady!"
], function(BorderContainer, ContentPane, AccordionContainer, Map, Extent, ArcGISTiledMapServiceLayer, ArcGISDynamicMapServiceLayer) {
  var initialExtent = new Extent({"xmin":-13050590.679808607,"ymin":3848824.1306140213,"xmax":-13033430.566958608,"ymax":3863366.2752452563,"spatialReference":{"wkid":102100}});
  
  myMap = new Map("mapDiv", {extent:initialExtent});
  var baseLayer = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
  var opLayer1 = new ArcGISDynamicMapServiceLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/MapServer",{ opacity:0.8 });
  myMap.addLayers([baseLayer, opLayer1]);
});
0 Kudos