tomneer

World_Topo_Map initialExtent Error

Discussion created by tomneer on Sep 15, 2011
Latest reply on Sep 20, 2011 by DSwingley-esristaff
I'm finally getting around to learning the ArcGIS API for JavaScript and seem to run into a bug. It seems that the World_Topo_Map service will not take an initialExtent without erroring out to 0,0 (Lat/Lon). But the ESRI_StreetMap_World_2D works fine.

<!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">
    <title></title>
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script>
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/tundra/tundra.css">
    
    <script type="text/javascript">
      dojo.require("esri.map");
      var myMap;
      
      function init() {
        myMap = new esri.Map("mapDiv");
        var spatialRef = new esri.SpatialReference({wkid:4326});
        var startExtent = new esri.geometry.Extent();
        startExtent.xmin = -124.71;
        startExtent.ymin = 31.89;
        startExtent.xmax = -113.97;
        startExtent.ymax = 42.63;
        startExtent.spatialReference = spatialRef;

        myMap.setExtent(startExtent);
        var mapServiceURL = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer";
        //var mapServiceURL = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";
        //Using the World_Topo_Map does not show proper startExtent
        myMap.addLayer(new esri.layers.ArcGISTiledMapServiceLayer(mapServiceURL));
        }
      dojo.addOnLoad(init);
    </script>
    
  </head>
  <body class="tundra">
    <div id="mapDiv" style="width:1024px; height:800px; border:1px solid #000;"></div>

  </body>
</html>



Comment/uncomment to toggle the layers. If someone could confirm that I'm not going insane and my code is correct, it would be greatly appreciated. TIA -Tom

Outcomes