zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    Python 拼接字符串的6种方法总结:
    Python 基础
    蓝牙通信测试app之蓝牙通信(二)
    蓝牙通信测试app之蓝牙配对(一)
    对ZAxxx解压工具的简单逆向记录
    上传项目到GitHub---详细步骤
    面试复习
    JavaWeb基础一
    MySQL基础二---基础介绍
    JS——Date日期对象
  • 原文地址:https://www.cnblogs.com/boonya/p/2404756.html
Copyright © 2011-2022 走看看