Giter Site home page Giter Site logo

Comments (6)

Thunder7991 avatar Thunder7991 commented on June 15, 2024 1

Hey, @JamesLMilner . The new features have been used just now, and there are still some problems. The restrictions on the area are equivalent to the restrictions of the radius. I have implemented it in the test demo, but there is a problem. If you quickly move the mouse to enlarge and shrink, it can also be said that it can also be said that Pressure testing, he will break through this limit. For example, the area is 1,000 square meters, and occasionally less than 1000, which may be related to the execution process of the entire program.

The new version will still have irregular circles, and you need to trouble you to adjust.

from terra-draw.

Thunder7991 avatar Thunder7991 commented on June 15, 2024

Hey, @JamesLMilner ,In editing mode and without setting the minimum distance. This issue may occur.

from terra-draw.

JamesLMilner avatar JamesLMilner commented on June 15, 2024

Hey @Thunder7991 - eventually I'm thinking of adding a function that allows you to set your own custom constraints before committing and edit. This should resolve this problem and be flexible enough to avoid any similar issues (i.e. you could set a minimum area/radius etc)

from terra-draw.

Thunder7991 avatar Thunder7991 commented on June 15, 2024

Regarding the issue of circles disappearing when scaled to a very small size. I solved it this way :

drag-coordinate-resize.behavior.ts 
public drag {
    ...
if(scale < 0) {
      return false
  }
    ...
}

This ensures that the circle will not disappear abnormally when zoomed in very small.

from terra-draw.

Thunder7991 avatar Thunder7991 commented on June 15, 2024

Hey @Thunder7991 - eventually I'm thinking of adding a function that allows you to set your own custom constraints before committing and edit. This should resolve this problem and be flexible enough to avoid any similar issues (i.e. you could set a minimum area/radius etc)

🙌 @JamesLMilner , I can feel that you are very busy now. In addition, when I turned off the function of mouse following point movement when zooming in circles (previous versions), and added a limit on the minimum radius when zooming in, there were calculation errors when the mouse was moving quickly, such as a minimum of 10 kilometers. If I moved normally, the radius would not be less than 10 kilometers, but sometimes it would be less than 10 kilometers. In the end, I abandoned the method of limiting the zoom radius, and the final solution was to avoid the sudden disappearance of the circle as shown in the code above. I am looking forward to your reply and a better solution.

from terra-draw.

JamesLMilner avatar JamesLMilner commented on June 15, 2024

In version 0.0.1-alpha.64 - you can now use the validation property flag to pass a function.

You can do something like this:

const selectMode = new TerraDrawSelectMode({
  flags: {
    circle: {
      feature: {
        // The entire Feature can be moved
        draggable: true,

        // Individual coordinates that make up the Feature...
        coordinates: {
          // Can be added
          midpoints: true,

          // Can be moved
          draggable: true,

          // Allow resizing of the geometry from a given origin. 
          // center-web-mercator will allow resizing of the aspect ratio from the center
          // and opposite-web-mercator allows resizing from the opposite corner of the 
          // bounding box of the geometry. 
          resizeable: 'center-web-mercator', // can also be 'opposite-web-mercator', 'center-fixed-web-mercator', 'opposite-fixed-web-mercator'

          // Can be deleted
          deletable: true,

          // Provide a custom validation that will run when we attempt to edit the geometry
          validation: (feature) => {
              // ValidateMinSizeSquareMeters can be imported from Terra Draw
	      return feature.geometry.type !== "Polygon" && ValidateMinSizeSquareMeters(feature.geometry, 1000);
          }
        },
      },
    },
  },
});

Here ValidateMinSizeSquareMeters is exposed from Terra Draw for convenience, but you can do any sort of validation you like to ensure the circle is correct.

from terra-draw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.