problem in conversion of extent object

548
3
Jump to solution
01-17-2014 08:54 AM
MaxDemars
New Contributor III
Hi,

I am trying to do a map.setExtent(extent, true) but I got this error in the console:
"Map: Geometry (wkid: GEOGCS["Longitude / Latitude (WGS 84)",DATUM["WGS 84",SPHEROID["WGS 84",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Decimal_Degree",0.0174532925199433]]) cannot be converted to spatial reference of the map (wkid: 4326)"


the extent object seems to be good and in the same spatial reference of the map

extent object:

spatialReference: Object
   wkt: "GEOGCS["Longitude / Latitude (WGS 84)",DATUM["WGS 84",SPHEROID["WGS 84",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Decimal_Degree",0.0174532925199433]]"
type: extent
xmax: -72.54337729099996
xmin: -74.16215098199996
ymax: 46.45532899700004
ymin: 45.35837900300004

           var extent = esri.graphicsExtent(result.featureSet.features);            console.log(extent)            map.setExtent(extent.expand(1.5, true);
0 Kudos
1 Solution

Accepted Solutions
JonathanUihlein
Esri Regular Contributor
It might be your spatial Reference object. Recreate the spatialReference object before creating your extent object to see if that changes anything.


require([   "esri/geometry/Extent", "esri/SpatialReference", ...  ], function(Extent, SpatialReference, ... ) {    var sr = new SpatialReference({"wkid": 4326});    var extent = new Extent(-122.68,45.53,-122.45,45.60, sr);   ... });


If that doesn't fix the issue, can you generate a really quick sample using http://jsfiddle.net ?

Thanks!

View solution in original post

0 Kudos
3 Replies
JonathanUihlein
Esri Regular Contributor
It might be your spatial Reference object. Recreate the spatialReference object before creating your extent object to see if that changes anything.


require([   "esri/geometry/Extent", "esri/SpatialReference", ...  ], function(Extent, SpatialReference, ... ) {    var sr = new SpatialReference({"wkid": 4326});    var extent = new Extent(-122.68,45.53,-122.45,45.60, sr);   ... });


If that doesn't fix the issue, can you generate a really quick sample using http://jsfiddle.net ?

Thanks!
0 Kudos
MaxDemars
New Contributor III
It might be your spatial Reference object. Recreate the spatialReference object before creating your extent object to see if that changes anything.


require([
  "esri/geometry/Extent", "esri/SpatialReference", ... 
], function(Extent, SpatialReference, ... ) {
   var sr = new SpatialReference({"wkid": 4326});
   var extent = new Extent(-122.68,45.53,-122.45,45.60, sr);
  ...
});


If that doesn't fix the issue, can you generate a really quick sample using http://jsfiddle.net ?

Thanks!


That fix it. Thank you very much! I just dont understand why the spatialReference was broken somewhere during the features creation. In my point of view the wkt (see first post) of the extent objects was corresponding to wkid 4326
0 Kudos
JonathanUihlein
Esri Regular Contributor
That fix it. Thank you very much! I just dont understand why the spatialReference was broken somewhere during the features creation.


Awesome!

No worries! I see this issue fairly frequently, especially when people are getting their data from JSON.
0 Kudos