AddPolygon

(TLayer.AddPolygon Method)

Create a polygon on the layer.
public AddPolygon(strPoints, strStyle):Object

Parameters

  • strPoints : String - Sets the given geographical positions been covered by the new created polygon. The strPoints specify the list of latitude and longitude values for drawing the polygon. Each set of latitude and longitude values constitute a vertex of the polygon. The number of these sets specifies the sides of the polygon if it is a closed polygon. Each set of latitude and longitude values should be separated by a β€˜;’and note that the last vertex should not end with a β€˜;’.
  • strStyle : String - Set the attributes of the polygon(color, border, etc). It contains the following attributes: (put a ; after each attribute included except the last one)
         FILL_COLOR : Hex Color Code - Sets the color for the polygon to fill in.
         FILL_ALPHA : Number - Sets the Alpha value for the polygon to full in.
         LINE_COLOR : Hex Color Code - Sets the color for the lines for the polygon.
         LINE_WIDTH : Number - Sets the width for the lines for the polygon.
         LINE_ALPHA : Number - Sets the Alpha value for the lines for the polygon.
         ENCLOSURE : Boolean - Specify whether it is a polygon(true) or polylines(false).

    Returns

  • TPolygon : Object - Returns the new polygon created on the layer.
  • Example

    The following example shows how to add a polygon on the layer.
    <div id="mapContainer"  style="width: 640px; height: 400px;"></div>
    <script type="text/javascript">
        var map0 = new TMap(mapContainer, 25.7590256665386, -80.3738769902151, 15, mapLoaded, 1, true);
       
        function mapLoaded() {
            polygon0=layer0.AddPolygon("25.7609634245936,-80.3810464518457;" + //You need to add the vertexes of
                                           "25.7611702422549,-80.3686484471929;" +  //the polygon in a string.
                                           "25.7469942429429,-80.3680055121408;" + 
                                           "25.7464559403514,-80.3839931698344;" + 
                                           "25.7574231613382,-80.3843195004342",    //Notice! DO NOT add a ";" for the last vertex.
                                           "FILL_COLOR=0xAACCFF;FILL_ALPHA=50;LINE_COLOR=0xFFFFFF;LINE_WIDTH=2;LINE_ALPHA=100;ENCLOSURE=TRUE");
    
        }
    </script>
        

    See example

    Adding polygons