Skip to content
Branch: master
Go to file
Code

Latest commit

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Yandex Maps API area calculation plugin.

util.calculateArea module allows to calculate the area of polygons, rectangles and circles. Note that plugin works only with geodesic geometries.

Usage

  1. Load both Yandex Maps JS API 2.1 and module source code by adding following code into <head> section of your page

    <script src="http://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
    <!-- Change my.cdn.tld to your CDN host name -->
    <script src="https://yastatic.net/s3/mapsapi-jslibs/area/0.0.1/util.calculateArea.min.js" type="text/javascript"></script>
  2. Wait for both API and module loaded

    ymaps.ready(['util.calculateArea']).then(function () {
        var myPolygon = new ymaps.Polygon(someCoordinates);
        // You can calculate area of any type of ymaps.GeoObject.
        var area = ymaps.util.calculateArea(myPolygon);
    
        // Or you can calculate area of GeoJson feature.
        var areaFromJson = ymaps.util.calculateArea({
                type: 'Feature',
                geometry: {
                    type: 'Rectangle',
                    coordinates: someRectangleCoordinates
                }
            });
    });

Note: module definition uses standard Yandex Maps API namespace 'ymaps'. If you are using custom namespace, you need to fork and rebuild module for your needs.

util.calculateArea(geoObject)

geoObject descibed using one of following formats:

  • ymaps.GeoObject
  • ymaps.Polygon
  • ymaps.Rectangle
  • ymaps.Circle
  • GeoJson Polygon
  • GeoJson Rectangle
  • GeoJson Circle

Returns geoObject area in square meters.

For contributors

If you want to make a pull-request, run tests and check code style first.

```js
npm install
npm run-script lint
npm test
```

Third party components

The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of OpenLayers Contributors.

About

util.calculateArea: plugin for calculating geodesic features area.

Resources

License

Releases

No releases published
You can’t perform that action at this time.