Class: Polygon

Polygon

Geometry class for polygon type

new Polygon(coordinates, optionsopt) [source]

var polygon = new Polygon(
     [
         [
             [121.48053653961283, 31.24244899384889],
             [121.48049362426856, 31.238559229494186],
             [121.49032123809872, 31.236210614999653],
             [121.49366863494917, 31.242926029397037],
             [121.48577221160967, 31.243880093267567],
             [121.48053653961283, 31.24244899384889]
         ]
     ]
 ).addTo(layer);
Parameter Type Default Description
coordinates Array.<Array.<Number>> | Array.<Array.<Array.<Number>>> | Array.<Coordinate> | Array.<Array.<Coordinate>> coordinates, shell coordinates or all the rings.
options opt Object null construct options defined in Polygon
Extends:

Members

  • (constant) options

  • Inherited From:
    Properties:
    Name Type Description
    options Object configuration options
    Properties
    Name Type Default Description
    symbol Object Path's default symbol
    id opt Boolean null id of the geometry
    visible opt Boolean true whether the geometry is visible.
    editable opt Boolean true whether the geometry can be edited.
    cursor opt String null cursor style when mouseover the geometry, same as the definition in CSS.
    shadowBlur opt Number 0 level of the shadow around the geometry, see MDN's explanation
    shadowColor opt String black color of the shadow around the geometry, a CSS style color
    measure opt String EPSG:4326 the measure code for the geometry, defines measureGeometry how it can be measured.
    draggable opt Boolean false whether the geometry can be dragged.
    dragShadow opt Boolean false if true, during geometry dragging, a shadow will be dragged before geometry was moved.
    dragOnAxis opt Boolean null if set, geometry can only be dragged along the specified axis, possible values: x, y
    Inherited From:
    Source:

    Methods

  • setCoordinates(coordinates) [source]

  • Set coordinates to the polygon
    Parameter Type Description
    coordinates Array.<Array.<Number>> | Array.<Array.<Array.<Number>>> | Array.<Coordinate> | Array.<Array.<Coordinate>> new coordinates
    Fires:
    Returns:
    Polygon: this
  • getCoordinates() [source]

  • Gets polygons's coordinates
    Returns:
    Array.<Array.<Coordinate>>:
  • getCenterInExtent(extent) [source]

  • Get center of linestring's intersection with give extent
    const extent = map.getExtent();
     const center = line.getCenterInExtent(extent);
    Parameter Type Description
    extent Extent
    Returns:
    Coordinate: center, null if line doesn't intersect with extent
  • getShell() [source]

  • Gets shell's coordinates of the polygon
    Returns:
    Array.<Coordinate>:
  • getHoles() [source]

  • Gets holes' coordinates of the polygon if it has.
    Returns:
    Array.<Array.<Coordinate>>:
  • hasHoles() [source]

  • Whether the polygon has any holes inside.
    Returns:
    Boolean:
  • (inherited) animateShow(optionsopt, cbopt) [source]

  • Show the linestring with animation
    line.animateShow({
       duration : 2000,
       easing : 'linear'
     }, function (frame, currentCoord) {
       //frame is the animation frame
       //currentCoord is current coordinate of animation
     });
    Parameter Type Default Description
    options opt Object null animation options
    Properties
    Parameter Type Default Description
    duration opt Number 1000 duration
    easing opt String out animation easing
    cb opt function null callback function in animation, function parameters: frame, currentCoord
    Inherited From:
    Returns:
    LineString: this