function getCoords { var topLeft = toLatLng(map.extent.xmin, map.extent.ymax); var topRight = toLatLng(map.extent.xmax, map.extent.ymax); var bottomRight = toLatLng(map.extent.xmax, map.extent.ymin); var bottomLeft = toLatLng(map.extent.xmin, map.extent.ymin); [...] } function toLatLng(x,y) { var pt = new esri.geometry.Point(x, y, map.SpatialReference); var symbol = new esri.symbol.SimpleMarkerSymbol(); var graphic = new esri.Graphic(pt, symbol); var outSR = new esri.SpatialReference({ wkid: 4326 }); try{ geometrySvc.project([graphic], outSR, // this is where it fails function (features) { pt = features[0].geometry; }); } catch (e) { alert(e.message); } var retv = pt.x + "," + pt.y + ",0"; return (retv); }
Hello,
I am trying to take a map extent coordinates (in State Plane), and convert them to pairs of Lat/Long coordinates. I am getting a 'wkid is null or undefined' error during the geometry service project function.
My code:function getCoords { var topLeft = toLatLng(map.extent.xmin, map.extent.ymax); var topRight = toLatLng(map.extent.xmax, map.extent.ymax); var bottomRight = toLatLng(map.extent.xmax, map.extent.ymin); var bottomLeft = toLatLng(map.extent.xmin, map.extent.ymin); [...] } function toLatLng(x,y) { var pt = new esri.geometry.Point(x, y, map.SpatialReference); var symbol = new esri.symbol.SimpleMarkerSymbol(); var graphic = new esri.Graphic(pt, symbol); var outSR = new esri.SpatialReference({ wkid: 4326 }); try{ geometrySvc.project([graphic], outSR, // this is where it fails function (features) { pt = features[0].geometry; }); } catch (e) { alert(e.message); } var retv = pt.x + "," + pt.y + ",0"; return (retv); }
Any advice is much appreciated
Do you have to do it in Javascript?
Is this only a one time deal or an ongoing process?
<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>TestTemplate.kml</name> <Style id="polyStyle"> <PolyStyle> <color>00000000</color> </PolyStyle> </Style> <Placemark> <name>Test Template</name> <styleUrl>#polyStyle</styleUrl> <Polygon> <outerBoundaryIs> <LinearRing> <coordinates> -72.135128,50.516577,0 <!-- TEST COORDS --> -72.646124,50.516424,0 -72.648152,50.514756,0 -72.648377,50.514901,0 </coordinates> </LinearRing> </outerBoundaryIs> </Polygon> </Placemark> </Document> </kml>