• OpenLayers 添加RegularPolygon


    1、主要涉及类:

    OpenLayers.Layer.Vector、OpenLayers.Control.DrawFeature、 

    OpenLayers.Handler.RegularPolygon

    2、方法编写

    var polygonControl ;
    
    function addPolygonLayer(){
    
      var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");
    
       map.addLayers([polygonLayer]);
    
       polyOptions = {sides: 4};
       polygonControl = new OpenLayers.Control.DrawFeature(polygonLayer,
                  OpenLayers.Handler.RegularPolygon,{handlerOptions: polyOptions});
                
        map.addControl(polygonControl);
                
        map.setCenter(new OpenLayers.LonLat(0, 0), 3);
                
            document.getElementById('activate').checked = true;
            document.getElementById('deactivate').checked = false;
       }
         function setOptions(options) {
                polygonControl.handler.setOptions(options);
         }

      3、操作选项:

    <input type="radio" name="type"   value="none" id="deactivate"
                           onclick="polygonControl.deactivate()"
                           checked="checked" />deactivate
    
    <input type="radio" name="type" value="none" id="activate"
    onclick="polygonControl.activate()" />activate
    
     <select name="sides"  onchange="setOptions({sides: parseInt(this.value)})">
          <option value="3">triangle</option>
          <option value="4" selected="selected">square</option>
          <option value="5">pentagon</option>
          <option value="6">hexagon</option>
          <option value="40">circle</option>
      </select>
  • 相关阅读:
    LNMP架构三
    LNMP架构二
    LNMP架构
    LAMP架构三
    LAMP架构二
    LAMP架构
    rsync工具介绍
    mysqldump备份单表数据
    阿铭每日一题 day 14 20180125
    阿铭每日一题 day 13 20180124
  • 原文地址:https://www.cnblogs.com/boonya/p/2404756.html
Copyright © 2020-2023  润新知