Changes between Version 12 and Version 13 of UserGuide
- Timestamp:
- Sep 27, 2008, 10:11:46 AM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
UserGuide
v12 v13 32 32 }}} 33 33 34 '''Note:''' Proj4js currently depends on some core [http://openlayers.org/ OpenLayers] classes which are compiled into the file [https://svn.codehaus.org/mapbuilder/cscs/trunk/proj4js/lib/OLprotoype.js OLprotoype.js]. If you are using Proj4js in a page that already includes the !OpenLayers library, there is no need to include this file, otherwise you must also include OLprototype.js in a <script> tag. The development plan for Proj4js is to factor out this requirement so that the !OpenLayers classes will only be required for dynamic lookup of the CRS definitions (see below).35 36 34 == Proj4js.Proj constructor == 37 35 … … 58 56 If you don't know the CRS's to be used by the application, Proj4js can dynamically look up the initialization parameters at run-time. By default, it will use the REST web service at [http://spatialreference.org spatialreference.org] as the lookup service. 59 57 60 To use Proj4js in this way, you will need to: 61 1. include the OLprotoype.js file in a script tag (only if your page doesn't already include OpenLayers) 62 1. define a proxy script to allow cross domain HTTP requests, e.g. {{{Proj4js.proxyScript = '/mapbuilder/proxy?url=';}}} 58 The way dynamic definition string lookup works is to first check for the definition at the path lib/defs. If the appropriate file is found there, it will be loaded and used by Proj4js. If it is not found there ('''note:''' in this case it is normal to see an error in the Firebug console), a request for the definition will be issued to spatialreference.org. If the definition for the CRS code is not found there, Proj4js will set the projection to WGS84. 63 59 64 The way dynamic definition string lookup works is to first check for the definition at the path lib/defs. If the appropriate file is found there, it will be loaded and used by Proj4js. If it is not found there ('''note:''' in this case it is normal to see an error in the Firebug console), an HTTP request will be issued to spatialreference.org. If the definition for the CRS code is not found there, Proj4js will set the projection to WGS84. 60 Dynamic loading occurs asynchronously so you must ensure that the Proj4js.Proj.readyToUse flag is set before carrying out any transformations. 61 62 To prevent invoking dynamic loading, simply ensure that any required files are loaded, either through using a built version of the library or by using <script> tags in your application. In this case the Proj4js.Proj constructor will behave synchronously and be readyToUse on return. 65 63 66 64 == Logging and Errors == 67 65 68 Proj4js includes two methods for reporting errors and log info which by default are empty stub functions which do nothing. To see error reports and logs, you must provide an override for these methods, for example:66 Proj4js includes a method for reporting errors which by default is an empty stub function which does nothing. You must provide an override for reportError to do something such as throw and exception or issue an alert, for example: 69 67 70 68 {{{ 71 69 //somewhere in your JS code 72 Proj4js.log = function(msg) {console.log(msg);}73 70 Proj4js.reportError = function(msg) {alert(msg);} 74 71 }}}