3

I am trying to map some planetary data on my webMap server using OpenLayers. I defined a proj4 projection as follow:

Proj4js.defs["MYDATUM"] = "+proj=longlat +a=1740000 +b=1740000 +units=m +no_defs";

In the html file I also call the proj4js.js, and then I added the following lines:

 map = new OpenLayers.Map('map', {
       controls: [
               new OpenLayers.Control.Navigation(),
               new OpenLayers.Control.PanZoomBar(),
               new OpenLayers.Control.ScaleLine({bottomOutUnits: ''}),
               new OpenLayers.Control.MousePosition(),
               new OpenLayers.Control.Graticule()

               ],
       Projection:  new OpenLayers.Projection("MYDATUM")
  });

My issue is that the scaleline does not show the correct distance and seems not to take into account my own projection. Actually I tried a couple of example and it seems that the line:

   projection:  new OpenLayers.Projection("MYDATUM")

does not have any effect on the ScaleLine size. How can I display correctly a scale bar using my own projection/datum ? Again, I'm not working with terrestrial data, so I do not want wgs84 or any of it's friends.

  • Have you tried setting the geodesic parameter of the Scaleline to true or false? – AndreJ Jun 20 '13 at 14:59
  • Have you added the proj4js library too? For projection others than 4326 and 900913 you need proj4js lirary – EricSonaron Jun 20 '13 at 15:08
  • Geodesic boolean does not affect the scaleline size...thanks though. – Antwan Jun 20 '13 at 15:12
  • As I said, I added the proj4js. – Antwan Jun 20 '13 at 15:12
  • the way I call proj4js is: <script type="text/javascript" src="jscssbin/proj4js/lib/proj4js.js"></script> is that enough? – Antwan Jun 20 '13 at 15:13
1

Not sure about teh java, but your proj string looks wrong. +units=m does not look right for a longlat projection. Try removing it, and in it's place also add +towgs84=0,0,0,0,0,0,0. I think you need this because you are not specifying a datum or nadgrids. It means no Helmert transformation. It will though then transform between ellipsoids. I think.

Not sure if you need to switch from degrees to radians then back to degrees after ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.