[OpenLayers-Users] how to use proj4js for Google

Alexander Petkov greenkov at gmail.com
Wed Oct 15 13:52:39 EDT 2008


What is the best way to file a bug report for Proj4js problems? I have
been trying to transform coordinates to laea, but it is giving me
result that are offset by a several kilometers. Quick Google search
indicates that the laea transfom hasn't been checked for validity as
of Jan 2008.


Thanks,
Alex

On Wed, Oct 15, 2008 at 11:44 AM, Burgholzer,Robert
<rwburgholzer at deq.virginia.gov> wrote:
> In case anyone else out there has been having trouble getting the proj4js
> lib to do a coordinate transform, I have recently gone through it with
> success.  I was goofing up a small part that caused much problems.
>
>
>
> I did one thing to solve my issue,
>
> 1) make sure that I included the merc.js projCode in my header:
>
> <script src="/html/scripts/proj4js/lib/projCode/merc.js"></script>
>
>
>
> So, the following is a page that will convert a latlon coord to google
> (based on an original posting from this listserv):
>
>
>
>
>
> <html>
>
> <head>
>
> <script src="/html/devlib/OpenLayers-2.7/lib/OpenLayers.js"></script>
>
> <script src="/html/scripts/proj4js/lib/proj4js.js"></script>
>
> <script src="/html/scripts/proj4js/lib/projCode/merc.js"></script>
>
>
>
> </head>
>
> <body>
>
> <div id="map"></div>
>
> <script type='text/javascript'>
>
> <!-- \n";
>
>     Proj4js.defs["EPSG:4326"] = "+proj=longlat +ellps=WGS84 +datum=WGS84
> +no_defs";
>
>     Proj4js.defs["EPSG:900913"] = "+proj=merc +a=6378137 +b=6378137
> +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null
> +no_defs";
>
>
>
>             var proj4326 = new OpenLayers.Projection("EPSG:4326");
>
>             var projGoogle = new OpenLayers.Projection("EPSG:900913");
>
>
>
>             var lon = -77.1266708374023;
>
>             var lat = 37.6813888549805;
>
>             var point = new OpenLayers.Geometry.Point(lon, lat);
>
>             OpenLayers.Projection.transform(point, proj4326, projGoogle);
>
>             alert(lon + " " + lat + " = " + point.x +" "+ point.y);
>
>
>
> // -->
>
> </script>
>
> </body>
>
> </html>
>
>
>
> Robert W. Burgholzer
>
> Surface Water Modeler
>
> Office of Water Supply and Planning
>
> Virginia Department of Environmental Quality
>
> rwburgholzer at deq.virginia.gov
>
> 804-698-4405
>
> Open Source Modeling Tools:
>
> http://sourceforge.net/projects/npsource/
>
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>



More information about the Users mailing list