[OpenLayers-Users] projection problem proj4js

Andreas Hocevar ahocevar at opengeo.org
Mon Oct 5 06:01:19 EDT 2009


Hi,

karsten vennemann wrote:
> I'm trying to use proj4js in OL llike this:
>  
>   var mapcenter = new OpenLayers.LonLat(lon.text, lat.text);
> Proj4js.defs["ESRI:102003"] = "+proj=aea +lat_1=29.5 +lat_2=45.5
> +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83
> +units=m +no_defs";

Relace the definition above with:

Proj4js.defs["EPSG:102003"] = "+proj=aea +lat_1=29.5 +lat_2=45.5
+lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m
+no_defs";
>   var source = new Proj4js.Proj("EPSG:4326");   
>   var dest = new Proj4js.Proj("EPSG:102003");

Replace the above to lines with:

  var source = new OpenLayers.Projection("EPSG:4326");   
  var dest = new OpenLayers.Projection("EPSG:102003");

Regards,
Andreas.


> OpenLayers.Projection.transform(mapcenter, source, dest);
>  
> and at that point I get thsi error: source.getCode is not a function
> OpenLayers.Projection.transforms[source.getCode()] &&.... 
> (Projection.js (line 172))
>  
> transform()(lon=-122.30785315739,lat=47.638080437239
> lon=-122.30785315739 lat=47.638080437239, Object
> srsCodeInput=EPSG:4326 srsCode=EPSG:4326, Object
> srsCodeInput=EPSG:102003 srsCode=EPSG:102003)Projection.js (line 172)
> success()()addressform.js (line 93)
> getViewWidth()(function(), undefined, [Object tId=0 status=200
> statusText=OK, Object url=geocode_integrate.php params=Object 0=Object
> 1=Object], undefined)ext-base.js (line 9)
> handleResponse()(Object tId=0 status=200
> statusText=OK)ext-all-debug.js (line 5317)
> getViewWidth()(Object conn=XMLHttpRequest tId=0, Object scope=Object
> argument=Object timeout=30000, undefined)ext-base.js (line 10)
> getViewWidth()()
>  
> Any idea what I am doing wrong ?
>
> Karsten
> www.terragis.net <http://www.terragis.net>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list