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

Eric Lemoine eric.c2c at gmail.com
Sun Jul 27 10:07:13 EDT 2008


Hello. Have you tried setting displayProjection in the map options as
opposed to in the mouse position control options? I cant check right
now but i dont remember having seen this option in the mouse position
control. Regards. Eric

2008/7/27, Matthew Perry <perrygeo at gmail.com>:
> 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?
>
> ====== 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
>


More information about the Users mailing list