Code Monkey home page Code Monkey logo

mapsapi-area's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.