npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bdh-gis/ol-control-edit

v1.5.5

Published

Edit for ol controls

Downloads

183

Readme

<< 所有组件

🏷️ @bdh-gis/ol-control-edit

要素编辑

npm i @bdh-gis/ol-control-edit
//要素编辑组件
import Edit from '@bdh-gis/ol-control-edit';
// import '@bdh-gis/ol-control-edit/src/index.css';
import '@bdh-gis/ol-control-edit/src/dark.css';

/*************************** 要素编辑 ****************************/
// New Feature
const feature_point = new Feature(new Point([132.867, 47.2763754924202]));
const feature_linestring = new Feature(
  new LineString([
    [132.8703, 47.2763754924202],
    [132.8737, 47.277407234388],
    [132.8764, 47.2763754924202],
  ]),
);
const feature_polygon = new Feature(
  new Polygon([
    [
      [132.878077263337, 47.2803754924202],
      [132.881049843613, 47.281407234388],
      [132.885687319518, 47.275216480775],
      [132.882844617633, 47.2738705689243],
      [132.878077263337, 47.2803754924202],
    ],
  ]),
);
// New vector layer
const layer_point = new VectorLayer({
  id: 'layer_point',
  name: '点图层',
  source: new VectorSource(),
});
const layer_linestring = new VectorLayer({
  id: 'layer_linestring',
  name: '线图层',
  source: new VectorSource(),
});
const layer_polygon = new VectorLayer({
  id: 'layer_polygon',
  name: '面图层',
  source: new VectorSource(),
});
layer_point.getSource().addFeature(feature_point);
layer_linestring.getSource().addFeature(feature_linestring);
layer_polygon.getSource().addFeatures(feature_polygon);
map.addLayer(layer_point);
map.addLayer(layer_linestring);
map.addLayer(layer_polygon);

const edit = new Edit({
  layers: [layer_point, layer_linestring, layer_polygon],
  measure: true,
});
edit.options.onEvents = (type, data) => {
  console.log(type, data, 'onEvents');
  if ('QUIT' == type) {
    layer_polygon.getSource().clear();
    layer_polygon.getSource().addFeature(
      new Feature(
        new Polygon([
          [
            [132.878077263337, 47.2803754924202],
            [132.881049843613, 47.281407234388],
            [132.885687319518, 47.275216480775],
            [132.882844617633, 47.2738705689243],
            [132.878077263337, 47.2803754924202],
          ],
        ]),
      ),
    );
    //重新设置编辑在图层
    edit.update({
      layers: [layer_polygon],
    });
    //隐藏部分功能按钮
    edit.setButtonsVisible([edit.buttons[4], edit.buttons[5]], false);
  }
};
map.addControl(edit);

Options

export type AnyEvent = "CONTROL_BUTTON_CLICK" | "CREATE_BUTTONS" | "LOCATE" | "SELECT" | "EDIT" | "EDIT_PROPERTIES" | "ADD" | "DELETE" | "TRANSFORM" | "DRAW_HOLE" | "SPLIT" | "PREV" | "NEXT" | "RESTORE" | "CLEAR" | "SAVE" | "QUIT" | "INTERACTION";
export type AnyFeatureType = "点" | "线" | "面";
export type Options = {
    layers: VectorLayer<VectorSource>[];
    measure?: boolean;
    isCreateButtons?: boolean;
    buttons?: Utils.ButtonOptions[];
    onEvents?: (event: AnyEvent, data?: any) => void;
};