OpenLayers3 multipolygon.getArea returns greater than expected values

  1. Home
  2. vector maps manual
  3. OpenLayers3 multipolygon.getArea returns greater than expected values

I’m giving my first steps with OpenLayers3, and I’m getting somewhat strange results when trying to obtain the area of a selected feature. I’ve a map who loads a vector layer from a KML source. On those KML there are several features represented as multipolygons which represents the borders of some north Spain’s regions. When I select the features, they change correctly it’s styles according to my code, but when I try to retrieve it’s area through multipolygons.getArea I obtain values a lot bigger than expected (almost double). The getArea of this multipolygon is returning 20021810258.82251 (I assume square meters as I’m using Mercator Projection), while the expected result would be about 10000 square km. I’m aware of the difficulties and problems with projections to a plane, and I was expecting a rough area result, but I’m getting twice the value I expected… it seems too much for a problem with projections or calculation… so I think there’s something I’m missing here. This is very similar to: You can read the backgrounds and explanations in there. Look at the measure example to see how it should be done currently. Source.

whatsapp button