Giter Site home page Giter Site logo

thomas2077 / leaflet-semicircle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jieter/leaflet-semicircle

0.0 2.0 0.0 375 KB

Extend Leaflet's circle class to display semicircles.

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

License: MIT License

JavaScript 68.50% HTML 28.98% CSS 2.52%

leaflet-semicircle's Introduction

Leaflet-Semicircle.

Allows drawing semicircles on leaflet maps.

It's an extension of Leaflet's L.Circle, and behaves like L.Circle if the a semicircle of almost 360 degrees is displayed.

Updated for use with leaflet 1.1.0.

Provided classes:

Provided methods:

L.SemiCircle/ L.SemiCircleMarker
factories: L.semiCircle/L.SemiCircleMarker
Options:
startAngle: start angle of the semicircle
stopAngle: stop angle of the semicircle
Angles are defined like compass courses: 0 = north, 90 = east, etc.
L.SemiCircle.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

Using options.startAngle and options.stopAngle:

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

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

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

Screenshot:

Live demo

Semicircles screenshot

Changelog

2.0.2 (2017-09-01)

  • Fixed #24: instance check for canvas renderer

2.0.1 (2017-07-22)

  • Fixed #14: Poleward displacement of circle center when radius is large.

2.0.0 (2017-07-09)

  • Changed the API to stand-alone classes rather than overwriting L.Circle with an extension of itself.
  • Added support for Leaflet 1.1.0

leaflet-semicircle's People

Contributors

jieter avatar kreegr avatar moklick avatar avidspartan1 avatar itytwt avatar

Watchers

James Cloos avatar Thomas Zou avatar

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.