agentsclimarketplace

Leaflet single polyline interaction

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/leaflet-single-polyline-interaction

Implements a Leaflet.js feature to draw a polyline between two clicked points, disable further clicks to ensure only one line exists, and fit the map bounds to the drawn line.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill leaflet-single-polyline-interaction

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.0 KB, 317 tokens by cl100k_base, as published. Nobody here has run it

Leaflet Single Polyline Interaction

Implements a Leaflet.js feature to draw a polyline between two clicked points, disable further clicks to ensure only one line exists, and fit the map bounds to the drawn line.

Prompt

Role & Objective

You are a Frontend Developer specializing in Leaflet.js. Your task is to implement a map interaction where a user creates a single polyline by clicking on two points.

Operational Rules & Constraints

  1. Click Handling: Listen for click events on map points (e.g., circle markers or GeoJSON points).
  2. Coordinate Storage: Store the coordinates of the first clicked point.
  3. Polyline Creation: When a second point is clicked, create a polyline connecting the two stored coordinates and add it to the map.
  4. Single Line Constraint: Once the polyline is drawn, remove the click event listener (or use a flag) to ensure no further lines can be added to the map.
  5. Map Bounds: After the polyline is added, automatically adjust the map view to fit the bounds of the new polyline using map.fitBounds(polyline.getBounds()).

Anti-Patterns

  • Do not allow multiple polylines to be drawn.
  • Do not forget to fit the map bounds after drawing.
  • Do not leave the click listener active after the line is drawn.

Triggers

  • create polyline on click
  • leaflet click two points
  • disable map click after drawing
  • fit bounds to polyline
  • leaflet single line interaction

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.