[OpenLayers-Users] wrong coordinates on OSM layer

Giuseppe Falcone falcone.giuseppe at gmail.com
Wed Jan 15 03:06:56 PST 2014


I have put displayProjection option also in MousePosition control:

map.addControl(
                  new OpenLayers.Control.MousePosition({
                    prefix: 'coordinates: ',
                    separator: ' , ',
                    numDigits: 2,
                    displayProjection:new OpenLayers.Projection("EPSG:4326")
                  })
                );

but I see always Mercator and not UTM33 coordinate. Why?

Giuseppe


2014/1/15 Giuseppe Falcone <falcone.giuseppe at gmail.com>

> Hi all,
>
> I have a system with OSM as baseMap. I want show coordinate in WGS84
> UTM33-N but I see wrong value.
> This is a sample page. There is any error?
> Thanks a lot.
>
> Giuseppe
>
>
> <!DOCTYPE html>
> <html>
>     <head>
>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
>     <meta name="viewport" content="width=device-width, initial-scale=1.0,
> maximum-scale=1.0, user-scalable=0">
>     <meta name="apple-mobile-web-app-capable" content="yes">
>         <title>OSM Example</title>
>         <link rel="stylesheet" href="style.css" type="text/css">
>         <script src="OpenLayers.js"></script>
>         <script type="text/javascript">
>             var map;
>
>             function init() {
>                 map = new OpenLayers.Map('map',{
>                   'projection':new OpenLayers.Projection("EPSG:3857"),
>                   'displayProjection':new
> OpenLayers.Projection("EPSG:32633")
>                 });
>
>                 map.addControl(
>                   new OpenLayers.Control.MousePosition({
>                     prefix: 'coordinates: ',
>                     separator: ' , ',
>                     numDigits: 2
>                   })
>                 );
>
>                 var osm = new OpenLayers.Layer.OSM("OSM", "
> http://tile.openstreetmap.org/${z}/${x}/${y}.png");
>
>                 var fromProjection = new
> OpenLayers.Projection("EPSG:4326");
>
>                 map.addControl(new OpenLayers.Control.PanZoomBar());
>                 map.addLayer(osm);
>                 map.setBaseLayer(osm);
>
>                 map.setCenter(new OpenLayers.LonLat(14.84,
> 40.8).transform(fromProjection, map.getProjectionObject()), 8);
>
>             }
>         </script>
>     </head>
>     <body onload="init()">
>       <h1 id="title">OSM Example</h1>
>       <div id="tags">
>         wfs, vector, osm
>       </div>
>       <p id="shortdesc">
>         OSMexample
>       </p>
>       <div id="map" class="smallmap"></div>
>     </body>
> </html>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20140115/3368384b/attachment-0001.html>


More information about the Users mailing list