Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to CRS.Simple #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ After instantiating the map create a new ellipse.

var ellipse = L.ellipse([51.5, -0.09], [500, 100], 90).addTo(map);

Access the typed data via

import 'leaflet-ellipse/l.ellipse';


## API

*Factory method*
Expand Down
31 changes: 31 additions & 0 deletions l.ellipse.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as L from 'leaflet'

declare module 'leaflet' {

/**
* Creates an ellipse.
* @param latlng The position of the center of the ellipse.
* @param radii The semi-major and semi-minor axis in meters
* @param tilt The rotation of the ellipse in degrees from west
* @param options Options dictionary to pass to L.Path
*/
function ellipse(latlng: number[], radii: number[], tilt: number, options: EllipseOptions): Path.Ellipse;

interface EllipseOptions extends L.PathOptions {
fill: boolean;
startAngle: number;
endAngle: number;
}

namespace Path {
class Ellipse extends L.Path {
constructor(options?: EllipseOptions)

setRadius(radii: number[]): this
getRadius(): L.Point
setTilt(tilt: number): this
getBounds(): L.LatLngBounds
}

}
}
8 changes: 8 additions & 0 deletions l.ellipse.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,18 @@ L.Ellipse = L.Path.extend({
},

_getLatRadius: function () {
var simpleCrs = !!this._map.options.crs.infinite;
if(simpleCrs)
return this._mRadiusY;
else
return (this._mRadiusY / 40075017) * 360;
},

_getLngRadius: function () {
var simpleCrs = !!this._map.options.crs.infinite;
if(simpleCrs)
return this._mRadiusX;
else
return ((this._mRadiusX / 40075017) * 360) / Math.cos((Math.PI / 180) * this._latlng.lat);
},

Expand Down
2 changes: 1 addition & 1 deletion l.ellipse.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.