Select to view content in your preferred language

set extent for DynamicMapServiceLayer

894
2
Jump to solution
01-28-2012 03:18 PM
RoryHall
Occasional Contributor
Hello, I have been working though the various examples of the JavaScript API with good success I might add, but have decided to venture outside the sample server of ESRI and have come unstuck. I have two layers esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer") and new esri.layers.ArcGISDynamicMapServiceLayer("http://maps.esriaustralia.com.au/ArcGIS/rest/services/BOM/YasiCycloneTrack/MapServer");. If I do not set and extent the map works fine, but I want to set the extent to the second layer. When I try this the map no longer draws. I am thinking it has something to do with different spatial references but am able to get my head around the problem.
my code as follows:
<script type="text/javascript">     
      dojo.require("esri.map");           
      var map;     
      function init(){         
      map = new esri.Map("map");
      //map = new esri.Map("map",{extent: new esri.geometry.Extent({xmin:123.837890625, ymin:-36.2109375, xmax:176.572265625, ymax:-1.0546875} )});
      var tiled = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer");
      map.addLayer(tiled);  
      var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://maps.esriaustralia.com.au/ArcGIS/rest/services/BOM/YasiCycloneTrack/MapServer");    
      map.addLayer(layer);    
       }     
       dojo.addOnLoad(init);
</script>

TIA ~ Rory
0 Kudos
1 Solution

Accepted Solutions
StephenLead
Honored Contributor
I am thinking it has something to do with different spatial references but am able to get my head around the problem.


Rory,

See the sample Set Custom Extent and Spatial Reference for the missing bit in your code, which is indeed the spatial reference.

Steve

View solution in original post

0 Kudos
2 Replies
StephenLead
Honored Contributor
I am thinking it has something to do with different spatial references but am able to get my head around the problem.


Rory,

See the sample Set Custom Extent and Spatial Reference for the missing bit in your code, which is indeed the spatial reference.

Steve
0 Kudos
RoryHall
Occasional Contributor
Thanks Steve,
Should of posted days ago, nightmare over. This worked great.

Cheers ~ Rory
0 Kudos