当前位置:网站首页>Openlayers draw rectangle

Openlayers draw rectangle

2022-04-23 19:08:00 GIS roast lamb leg is delicious

	var webgissource={};
    webgissource.measure = new VectorSource();
    webgissource.measurelayer = new Vectorlayer({
      source: webgissource.measure,
      style: new Style({
        fill: new Fill({
          color: 'rgba(255, 255, 255, 0.2)'
        }),
        stroke: new Stroke({
          color: '#ffcc33',
          width: 2
        }),
        image: new Icon({
          //color: '#4271AE',
          scale:0.7,
          src: 'static/img/greenpoint.png'
        }),
      })
    });
    map.addLayer(webgissource.measurelayer)
      measureparms.draw = new Draw({
        source: webgissource.measure,
        type: “LineString”,
        style: new Style({
          fill: new Fill({
            color: 'rgba(0,0,0,0.2)'
          }),
          stroke: new Stroke({
            color: 'rgba(0, 0, 0, 0.5)',
            lineDash: [10, 10],
            width: 2
          }),
          image: new CircleStyle({
            radius: 5,
            stroke: new Stroke({
              color: 'rgba(0, 0, 0, 0.7)'
            }),
            fill: new Fill({
              color: 'rgba(255, 255, 255, 0.2)'
            })
          })
        }),
        maxPoints: 2,
        geometryFunction: function(coordinates, geometry){
          var start = coordinates[0];
          var end = coordinates[1];
          if(!geometry){
            geometry=new Polygon([
              [start, [start[0], end[1]], end, [end[0], start[1]], start]
            ]);
          }
          geometry.setCoordinates([
            [start, [start[0], end[1]], end, [end[0], start[1]], start]
          ]);
          return geometry;
        }
      });

版权声明
本文为[GIS roast lamb leg is delicious]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231908121102.html