I want to use OpenLayers3 simply to draw some shapes that I can inspect by panning and zooming. There would be no map backdrop since the data is not geographic in nature.

The data holds the locations of these shapes using coordinates (X, Y) which have the following convention:

  • POSITIVE X is EASTWARD from origin
  • POSITIVE Y is DOWNWARD from origin

However, OpenLayers' default projection has POSITIVE Y going UPWARD.

To try to solve this issue, I am creating a new custom projection and specifying its axisOrientation as 'esu'. However this isn't doing anything. Here is my code...

http://jsfiddle.net/x9ust0nx/ (note there is no map backdrop -- just a grey canvas with 3 red points)

Any ideas?

(I realize I can iterate through my data and negate the Y values, but I want to learn how to do it the right way).

  • What were you expecting? That your vector data coordinates are flipped on the y-axis? If your vector data has coordinates different from the ones you want, you'll need to configure transform functions. Just setting the axis orientation in your projection configuration won't be enough. – ahocevar Mar 19 '15 at 23:20

I created a fork of your JSFiddle that implements what I've suggested in my comment: http://jsfiddle.net/jLndtt8z/1/. The key piece of information you were missing is that the axisOrientation property of the projection is just a hint to format parsers and serializers, but it does not actually cause any coordinates to be transformed. To flip the y-axis, you will have to define a transform for your projection:

ol.proj.addCoordinateTransforms('EPSG:4326', projection,
    function(coordinate) {
      return [coordinate[0], -coordinate[1]];
    function(coordinate) {
      return [coordinate[0], -coordinate[1]];

You also have to set the view projection on the source to get the coordinates transformed properly.

  • The fiddle seems to be broken somehow; I get a ol.source.GeoJSON is not a constructor. Does it work for you? I am trying to flip the y-axis, too. – Mouagip Apr 21 '15 at 11:15
  • 2
    I updated the JSFiddle to use the correct version of OpenLayers: jsfiddle.net/jLndtt8z/1. – ahocevar Apr 22 '15 at 13:36

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.