Skip to content
Advertisement

move a circle from one point to another

I’m new to leaflets and am trying to circle the map when clicked. I want conditions like the following:

  • Circle moves from one point to another when clicked on the map (If the circle already exists and there is only one circle)
  • Directly Zoom on where the circle is made

However I have the following problem:

  1. Circle increases
  2. When pressing another point, the circle disappears first and after that it will appear at the previous point and at the most recent point
  3. Don’t zoom in where the circle is made

Is there a solution to this problem?

JavaScript

Advertisement

Answer

  1. The circle will increase because you delete only the featureGroup layer not the content of the featureGroup. Re-initiation can be done as follows:
JavaScript
  1. Can be added directly after re-initiation
JavaScript
  1. Can add “setView” command:
JavaScript

Here’s the full code:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement