AnsweredAssumed Answered

bboxSR=null and imageSR=null on dynamic service

Question asked by Arkitech on Oct 3, 2012
Latest reply on Oct 4, 2012 by odoe
Hi

My code below. I am having issues when i have added a dynamic map service to my code. When the map zooms into the x/y specified, i get a 404 error on the dynamic map service -
http://sccw08ags/ArcGIS/rest/services/APILBSR/MapServer/export?dpi=96&transparent=true&format=png8&layers=show%3A0%2C1%2C2%2C5%2C6&bbox=349519.8477901956%2C328478.0609601219%2C353292.1522098044%2C330017.9390398781&bboxSR=null&imageSR=null&size=1901%2C776&f=image
stating that the bboxSR is invalid (i have noticed the imageSR is null aswell)

When i then pan on the map, the dynamic service works an is visual on the map. -
http://sccw08ags/ArcGIS/rest/services/APILBSR/MapServer/export?dpi=96&transparent=true&format=png8&layers=show%3A0%2C1%2C2%2C5%2C6&bbox=347974.0165735332%2C327450.1526543053%2C351746.32099314197%2C328990.03073406144&bboxSR=27700&imageSR=27700&size=1901%2C776&f=image
.

It seems its something to do with when the map loads and it zooms to the location, the dynamic service does not seem to know the SR!

I have tried to set it manually using imageParameters however this failed. Please any help with this as in kinda stuck at the moment.

cheers

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>          <head>         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">         <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />         <!--The viewport meta tag is used to improve the presentation and behavior         of the samples on iOS devices-->         <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"         />         <title>CRM Mapping Testing</title>         <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dijit/themes/claro/claro.css">         <link rel="stylesheet" type="text/css" href="http://sw08agsd/DEV/css/map_new.css">         <style>             html, body {                 height: 100%;                 width: 100%;                 margin: 0;                 padding: 0;             }             .esriScalebar {                 padding: 20px 20px;             }             #map {                 padding:0;             }         </style>         <script type="text/javascript">             var djConfig = {                 parseOnLoad: true             };         </script>         <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.1"></script>         <script type="text/javascript" src="http://sccw08ags/DEV/js/jquery-1.3.2.min.js"></script>         <script type="text/javascript" src="http://sw08agsd/DEV/js/identify.js"></script>         <script type="text/javascript" src="http://sccw08ags/DEV/js/jquery.stylish-select.min.js"></script>         <!-- jquery plugin -->         <script type="text/javascript" src="http://sccw08ags/DEV/js/jquery/jquery.url.packed.js"></script>         <script type="text/javascript">             dojo.require("dijit.layout.BorderContainer");             dojo.require("dijit.layout.ContentPane");             dojo.require("esri.map");              // Required for identify             dojo.require("esri.tasks.identify");             dojo.require("esri.layers.FeatureLayer");               dojo.require("dijit.Toolbar");             dojo.require("dijit.layout.TabContainer"); //old tab "identify" box             dojo.require("dijit._Widget"); //additional parameters for editing widgets             dojo.require("dojox.layout.TableContainer");             dojo.require("esri.arcgis.utils");             dojo.require("dijit.form.CheckBox");             dojo.require("dijit.layout.AccordionContainer");         </script>         <script type="text/javascript">             var symbol;             var map;             var graphic;             var mapLayers = [];              //var visible = [];             var layer7results, layer3results, layer4results, layer2results, layer0results, layer1results;             var setSymbol, setSymbol1, setSymbol2, setSymbol3, setSymbol4, setSymbol5, setSymbol6;             var highlight_id1 = [], highlight_id2 = [], highlight_id3 = [], highlight_id4 = [], highlight_id5 = [], highlight_id6 = [];              function init() {                  var initExtent = new esri.geometry.Extent({                     "xmin": 186819,                     "ymin": 230984,                     "xmax": 506529,                     "ymax": 407263,                     "spatialReference": {                         "wkid": 27700                     }                 });                  map = new esri.Map("map", {                     extent: initExtent                 });                  var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://sccw08ags/ArcGIS/rest/services/CABackground_Greyscale/MapServer");                  //var imageParameters = new esri.layers.ImageParameters();     //ImageParameters.imagespatialReference = new esri.SpatialReference({ wkid: 27700});                 //imageParameters.imageSpatialReference = "27700";     //imageParameters.format = "png8";     //imageParameters.imageSpatialReference = new esri.SpatialReference({wkid:27700});                 //console.log(imageParameters.imageSpatialReference);                  var lbsr = new esri.layers.ArcGISDynamicMapServiceLayer("http://sccw08ags/ArcGIS/rest/services/APILBSR/MapServer", {                     "opacity": 0.7                     //"imageParameters": imageParameters                 });                  map.addLayer(basemap);                                  //console.log(map.geometry.Extent.spatialReference.wkid);                 //mapLayers.push(basemap);                 //mapLayers.push(lbsr);                   // When dojo has received notification that everything's been loaded, we'll run an "anonymous function"                 dojo.connect(map, 'onLoad', function () {                       dojo.connect(dijit.byId('map'), 'resize', map, map.resize);                       var urlObject = esri.urlToObject(document.location.href);                      // Set our default position, zoom level and layerid's                     var x = 351406;                     var y = 329248;                     var zoomLevel = 8;                     var layers = [0,1,2,3,4,5,6,7,8,9];                      // Do we have a qeury string on the URL?                     if (urlObject.query) {                          // Do we have a coords parameter?                         if (urlObject.query.coords) {                              var coords = urlObject.query.coords.split(',');                              // We have an x and a y right?                             if (coords.length == 2) {                                 x = parseFloat(coords[0]);                                 y = parseFloat(coords[1]);                                 console.log(x);                                 console.log(y);                             }                          }                          // Let's check for a zoomlevel                           if (urlObject.query.zoomLevel) {                              zoomLevel = parseInt(urlObject.query.zoomLevel);                             console.log(zoomLevel);                          }                          //Let's check if any layers are specified                          if (urlObject.query.layers) {                              //layers = parseInt(urlObject.query.layers);                                  layers = urlObject.query.layers.split(',');                             console.log(layers);                         }                          //set the visable layers that where passed in the url                         lbsr.setVisibleLayers(layers);                             }                                  // Position our mapto the x and y provided in the url                      var point = esri.geometry.Point(new esri.geometry.Point(x, y));                     map.centerAndZoom(point, zoomLevel);                      // Highlight the item on our map                      if (!graphic) {                         addGraphic(point);                     } else {                         graphic.setGeometry(point);                     }                      map.centerAt(point);                           setUpIdentify(layers);                        });                  //adds an image to the x and y that was passed                  function addGraphic(point) {                      var symbol = new esri.symbol.PictureMarkerSymbol('http://sw08agsd/DEV/img/marker-icon.png', 20, 30);                      graphic = new esri.Graphic(point, symbol);                     map.graphics.add(graphic);                 }          map.addLayer(lbsr);              }                   dojo.addOnLoad(init);         </script>     </head>          <body class="claro"> <span id="layer_list"></span>          <div dojotype="dijit.layout.BorderContainer"         design="headline" gutters="false" style="width: 100%; height: 100%; margin: 0;">             <div id="map" dojotype="dijit.layout.ContentPane" region="center" style="border:1px solid #000;padding:0;"></div>         </div>         <div id="tabs" dojoType="dijit.layout.AccordionContainer">             <div id="layer7Tab" dojoType="dijit.layout.ContentPane"></div>             <div id="layer2Tab" dojoType="dijit.layout.ContentPane"></div>             <div id="layer1Tab" dojoType="dijit.layout.ContentPane"></div>             <div id="layer3Tab" dojoType="dijit.layout.ContentPane"></div>             <div id="layer4Tab" dojoType="dijit.layout.ContentPane"></div>             <div id="layer0Tab" dojoType="dijit.layout.ContentPane"></div>         </div>     </body>  </html>

Outcomes