<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>Zoom to non-WM dynamic layer</title> <link rel="stylesheet" href="http://js.arcgis.com/3.6/js/esri/css/esri.css"/> <style> html,body,#mapDiv{ padding:0; margin:0; height:100%; } </style> <script src="http://js.arcgis.com/3.6/"></script> <script> dojo.require("esri.map"); var map; var url = "http://loczy.mfgi.hu/ArcGIS/rest/services/TJAM/surf_ujfalu_t/MapServer/" function init() { //Get the layer's extent from ArcGIS Server esri.request({ url: url, content: {f: "json"}, handleAs: "json", callbackParamName: "callback", load: function(response) { //Create the map. Since we're specifying the Gray basemap it'll use Web Mercator map = new esri.Map("mapDiv", {basemap: "gray"}); //Add the dynamic layer. Although it's not stored in Web Mercator, it's automatically //projected on-the-fly and displays in the correct location var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer(url); map.addLayer(dynamicMapServiceLayer); //Zoom the map to the new layer's extent. This fails, since the extent doesn't use WM map.setExtent(response.initialExtent); }, error: function (error) { alert("Sorry, there was a problem zooming to the new layer"); } }); } dojo.ready(init); </script> </head> <body> <div id="mapDiv"></div>\ </body> </html>
Solved! Go to Solution.