FesterCluck / Leaflet-semicircle

Extend Leaflet's circle class to display semicircles.

Home Page:http://jieter.github.io/Leaflet-semicircle/examples/semicircle.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Leaflet-Semicircle.

Adds semicircle functionality to L.Circle. Angles are defined like compass courses: 0 = north, 90 = east, etc. If the script is not included, Leaflet will fall back drawing full circles.

Updated for use with leaflet 1.0.0-rc.1.

Provided methods

L.Circle.setStartAngle(angle) Set the start angle of the circle to angle and redraw.
L.Circle.setStopAngle(angle) Set the stop angle of the circle to angle and redraw.
L.Circle.setDirection(direction, size) Set the startAngle to direction - (0.5 * size) and the stopAngle to direction + (0.5 * size) and redraw.

Usage:

The plugin provides two ways to only display a part of the circle:

  1. Use the options map and set startAngle and stopAngle.
  2. Use setDirection(direction, size) to display a semicircle of size degrees at direction.

Example:

Live demo

Useing options.startAngle and options.stopAngle:

L.circle([51.5, -0.09], {
    radius: 500,
	startAngle: 45,
	stopAngle: 135
}).addTo(map);

Draw the same semicircle using setDirection(direction, size):

L.circle([51.5, -0.09], {radius: 500})
	.setDirection(90, 90)
	.addTo(map);

Screenshot:

Live demo

Semicircles screenshot

About

Extend Leaflet's circle class to display semicircles.

http://jieter.github.io/Leaflet-semicircle/examples/semicircle.html

License:MIT License


Languages

Language:JavaScript 66.6%Language:HTML 30.8%Language:CSS 2.7%