Select to view content in your preferred language

Spatial Reference and Extent problem

657
1
08-31-2010 07:24 AM
AlejandroMorales
Emerging Contributor
Hi, well I've been searching for answers... but I cannot find something that helps me, my problem is:

I have to show a map with a custom extent and a different spatial reference, whenever I try to set this two, my map doesn't show ... here is my code... (it's from a sample I found I just add my map service)

 
....
var initialExtent = new esri.geometry.Extent({
                     "xmin": 650.24376718739,
                     "ymin": 1515.85251773739,
                     "xmax": 807.862232212611,
                     "ymax": 1673.47098276261,
                     "spatialReference": {
                        PROJCS["WGS_1984_UTM_Zone_15N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-93.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Kilometer",1000.0]]
                   }
                });
                map = new esri.Map("map", {
                    extent: initialExtent,
                    slider: false
                });
               
                dojo.connect(dijit.byId('map') , 'resize', function () { 
//resize the map when browser size changes
                    resizeMap();
//                });
                dojo.connect(map, "onClick", mapClickHandler);
  var topoMap = new esri.layers.ArcGISDynamicMapServiceLayer("http://servarcgisprd/ArcGIS/rest/services/MapaBase/MapServer", {
                    id: "topo",
                    visible: true
                });
                baseLayers.push(topoMap);
                map.addLayers(baseLayers);
.....


As you can see my spatial reference it's very different from anything else, so It's ok I wrote it like that?
Help !!

Thanks,

Alex
0 Kudos
1 Reply
derekswingley1
Deactivated User
I'm not sure if that will work, but one thing that is definitely wrong is your spatialReference property of initialExtent. If you want to use well known text, specify it as the wkt property on your spatial reference. The docs have an example:  http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/spatialreference.htm

That being said, why not use the wkid? You can look yours up here:  http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/pcs.htm

It looks like you're using 32615 so you can use this for initialExtent:
new esri.geometry.Extent({
  "xmin": 650.24376718739,
  "ymin": 1515.85251773739,
  "xmax": 807.862232212611,
  "ymax": 1673.47098276261,
  "spatialReference": { 'wkid': 32615 }
});


Again, I'm not sure if you can set your map's extent with an extent that doesn't use the map's spatial reference. If all else fails, you could use a geometry service to re-project your extent's spatial reference matches the map's.
0 Kudos