Changes between Version 12 and Version 13 of UserGuide


Ignore:
Timestamp:
Sep 27, 2008, 10:11:46 AM (16 years ago)
Author:
madair
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UserGuide

    v12 v13  
    3232}}}
    3333
    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 
    3634== Proj4js.Proj constructor ==
    3735
     
    5856If 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.
    5957
    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=';}}}
     58The 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.
    6359
    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.
     60Dynamic loading occurs asynchronously so you must ensure that the Proj4js.Proj.readyToUse flag is set before carrying out any transformations.
     61
     62To 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.
    6563
    6664== Logging and Errors ==
    6765
    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:
     66Proj4js 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:
    6967
    7068{{{
    7169//somewhere in your JS code
    72 Proj4js.log = function(msg) {console.log(msg);}
    7370Proj4js.reportError = function(msg) {alert(msg);}
    7471}}}