Select to view content in your preferred language

Map constructor failing to set WKID

973
2
Jump to solution
03-18-2013 02:02 PM
DuncanNisbett
Deactivated User
If I use the following map constructor to build my map I get an error. The error says: Map: Geometry (wkid: 4326) cannot be converted to spatial reference of the map (wkid: 32149). I'm using the 3.3 version and I don't get why this is failing. What am I doing wrong here?

map = new esri.Map("map", {   autoResize: true,   center: [79375.16, 52916.77],   extent: new esri.geometry.Extent({     xmin: 528102.74,   ymin: 109727.35,   xmax: 607477.90,   ymax: 162644.12,   spatialReference: new esri.SpatialReference({wkid:32149})}),   minZoom: 3,   zoom: 4 });
0 Kudos
1 Solution

Accepted Solutions
JohnGravois
Deactivated User
the new options to specify a center and zoom level in the map constructor are meant to replace the old technique of supplying the extent itself.  right now you are setting both.

additionally, the coordinates passed to "center" are assumed to be either web mercator or latitude and longitude unless you actually define a new point geometry object.

i didnt test this, but it should look something like this
map = new esri.Map("map", {   autoResize: true,   //center: [79375.16, 52916.77],   center: new esri.geometry.Point([79375.16,52916.77],new esri.SpatialReference({ wkid:32149 }));,   //extent: new esri.geometry.Extent({     xmin: 528102.74,   ymin: 109727.35,   xmax: 607477.90,   ymax: 162644.12,   spatialReference: new esri.SpatialReference({wkid:32149})}),   minZoom: 3,   zoom: 4 });

View solution in original post

0 Kudos
2 Replies
JohnGravois
Deactivated User
the new options to specify a center and zoom level in the map constructor are meant to replace the old technique of supplying the extent itself.  right now you are setting both.

additionally, the coordinates passed to "center" are assumed to be either web mercator or latitude and longitude unless you actually define a new point geometry object.

i didnt test this, but it should look something like this
map = new esri.Map("map", {   autoResize: true,   //center: [79375.16, 52916.77],   center: new esri.geometry.Point([79375.16,52916.77],new esri.SpatialReference({ wkid:32149 }));,   //extent: new esri.geometry.Extent({     xmin: 528102.74,   ymin: 109727.35,   xmax: 607477.90,   ymax: 162644.12,   spatialReference: new esri.SpatialReference({wkid:32149})}),   minZoom: 3,   zoom: 4 });
0 Kudos
DuncanNisbett
Deactivated User
Fantastic, that was the answer. I needed to pass a geometry point with the correct wkid and that fixed it. I of course also had my x,y coordinates reversed and the wrong values, but that's just semantics. Here's the updated code that worked.

map = new esri.Map("map", {
 autoResize: true,
 center: new esri.geometry.Point([567790.32,136185.91], new esri.SpatialReference({ wkid:32149 })),
 minZoom: 3,
 zoom: 4
});
0 Kudos