[OpenLayers-Users] Displaying lat long coordinates for projected map?

Christopher Schmidt crschmidt at metacarta.com
Sun Jul 27 10:58:21 EDT 2008


On Sun, Jul 27, 2008 at 06:56:35AM -0700, Matthew Perry wrote:
> Hi all,
> 
>  Has anyone had any success displaying latlong coordinates for a
> projected map? The relevant code is below... all I get is "Nan, Nan"
> in the coordinate display. Is there something obvious that I should
> try?

The spherical-mercator example displays unprojected coordinates using
this method with no problems.  

If you do: 

OpenLayers.Projection.transform({'x':10, 'y':10}, new
OpenLayers.Projection("EPSG:54009"), new
OpenLayaers.Projection("EPSG:4326"));

Do you get NaN as well? My guess would be 'yes'.

> ====== begin listing ========
>    <script src="./lib/OpenLayers.js"></script>
>     <script src="./lib/proj4js.js"></script>
>     <script type="text/javascript">
>         Proj4js.defs["EPSG:4326"]  = "+proj=longlat +ellps=WGS84
> +datum=WGS84 +no_defs ";
>         Proj4js.defs["EPSG:54009"] = "+proj=moll +lon_0=0 +x_0=0
> +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
> 
>         var map;
> 
>         function init(){
>             map = new OpenLayers.Map( 'map',
>                     {
>                        restrictedExtent: new
> OpenLayers.Bounds(-18040095,-9020047,18045393,9022696),
>                        maxExtent: new
> OpenLayers.Bounds(-18040095,-9020047,18045393,9022696),
>                        maxResolution: 37984.724210526314,
>                        projection: new
> OpenLayers.Projection("EPSG:54009"), // have also tried just the
> string "EPSG:54009"
>                        units: 'm',
>                        controls: [
>                         new OpenLayers.Control.PanZoomBar(),
>                         new OpenLayers.Control.Navigation(),
>                         new OpenLayers.Control.MousePosition(
>                              {displayProjection: new
> OpenLayers.Projection("EPSG:4326")}),
>                         new OpenLayers.Control.ScaleLine({units: 'mi'}),
>                        ],
>                        numZoomLevels: 8
>                     }
>                   );
> ====== end listing ========
> -- 
> ·´¯`·.¸. , . .·´¯`·.. ><((((º>`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>
> "The best way to predict the future is to invent it." -- Alan Kay
> Matthew T. Perry
> http://www.perrygeo.net
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list