# Example for Projection

1298
3
02-27-2019 05:13 AM
New Contributor II

Is there a working example for

I pasted the example to JSFiddle

I got the error_

Cannot read property '_getTransformation' of null

What do i miss?

Tags (1)
1 Solution

Accepted Solutions
MVP Esteemed Contributor

Matthias,

You have to load the module first:

``<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <meta http-equiv="X-UA-Compatible" content="IE=edge">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <link rel="stylesheet" href="https://js.arcgis.com/4.10/esri/css/main.css">    <script src="https://js.arcgis.com/4.10/"></script>    <script>      require([        "esri/geometry/projection",        "esri/geometry/SpatialReference",        "esri/geometry/Extent"      ], function (projection,SpatialReference,Extent) {      const cs1 = new SpatialReference({  	  wkid: 4272 //PE_GCS_ED_1950	});      const cs2 = new SpatialReference({  	  wkid: 4167	});      const extent = new Extent({          xmin: -186.0,          ymin: -42.0,          xmax: -179.0,          ymax: -38.0        });      projection.load().then(function(evt) {          const geogtrans = projection.getTransformations(cs1, cs2, extent);          geogtrans.forEach(function(geogtran, index) {            geogtran.steps.forEach(function(step, index) {              console.log("step wkid: ", step.wkid);            });          });        });      });  </script></head><body >Test</body></html>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍``
3 Replies
MVP Esteemed Contributor

Matthias,

You have to load the module first:

``<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <meta http-equiv="X-UA-Compatible" content="IE=edge">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <link rel="stylesheet" href="https://js.arcgis.com/4.10/esri/css/main.css">    <script src="https://js.arcgis.com/4.10/"></script>    <script>      require([        "esri/geometry/projection",        "esri/geometry/SpatialReference",        "esri/geometry/Extent"      ], function (projection,SpatialReference,Extent) {      const cs1 = new SpatialReference({  	  wkid: 4272 //PE_GCS_ED_1950	});      const cs2 = new SpatialReference({  	  wkid: 4167	});      const extent = new Extent({          xmin: -186.0,          ymin: -42.0,          xmax: -179.0,          ymax: -38.0        });      projection.load().then(function(evt) {          const geogtrans = projection.getTransformations(cs1, cs2, extent);          geogtrans.forEach(function(geogtran, index) {            geogtran.steps.forEach(function(step, index) {              console.log("step wkid: ", step.wkid);            });          });        });      });  </script></head><body >Test</body></html>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍``
New Contributor II

Thank you Robert. Now it works!

The documentation at the esri page is wrong!

...Maybe they should fix that. Wrong documentation is just frustrating ...

MVP Esteemed Contributor

Matthias,

Actually the load requirement is stated in the help documentation:

Loads this module's dependencies. This method must be called before projecting geometries.

I agree that it should be part of the code snippets though.