mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
Making the GeoJSON methods accessible as static methods
This commit is contained in:
parent
d6aea41f4d
commit
e7b6ff74ce
85
leaflet/index.d.ts
vendored
85
leaflet/index.d.ts
vendored
@ -817,6 +817,51 @@ declare namespace L {
|
||||
coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng; // check if LatLng has an altitude property
|
||||
}
|
||||
|
||||
export class GeoJSON {
|
||||
/**
|
||||
* Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer
|
||||
* and/or coordsToLatLng functions if provided as options.
|
||||
*/
|
||||
static geometryToLayer(featureData: GeoJSON.Feature<GeoJSON.GeometryObject>, options?: GeoJSONOptions): Layer;
|
||||
|
||||
/**
|
||||
* Creates a LatLng object from an array of 2 numbers (longitude, latitude) or
|
||||
* 3 numbers (longitude, latitude, altitude) used in GeoJSON for points.
|
||||
*/
|
||||
static coordsToLatLng(coords: [number, number] | [number, number, number]): LatLng;
|
||||
|
||||
/**
|
||||
* Creates a multidimensional array of LatLngs from a GeoJSON coordinates array.
|
||||
* levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of
|
||||
* arrays of points, etc., 0 by default).
|
||||
* Can use a custom coordsToLatLng function.
|
||||
*/
|
||||
static coordsToLatLngs(
|
||||
coords: any[],
|
||||
levelsDeep?: number,
|
||||
coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng): any[]; // Using any[] to avoid artificially limiting valid calls
|
||||
|
||||
/**
|
||||
* Reverse of coordsToLatLng
|
||||
*/
|
||||
static latLngToCoords(latlng: LatLng): number[];
|
||||
|
||||
/**
|
||||
* Reverse of coordsToLatLngs closed determines whether the first point should be
|
||||
* appended to the end of the array to close the feature, only used when levelsDeep is 0.
|
||||
* False by default.
|
||||
*/
|
||||
static latLngsToCoords(latlngs: any[], levelsDeep?: number, closed?: boolean): any[]; // Using any[] to avoid artificially limiting valid calls
|
||||
|
||||
/**
|
||||
* Normalize GeoJSON geometries/features into GeoJSON features.
|
||||
*/
|
||||
static asFeature(geojson: GeoJSON.GeometryObject): GeoJSON.Feature<GeoJSON.GeometryObject>;
|
||||
|
||||
static asFeature(geojson: GeoJSON.Feature<GeoJSON.GeometryObject>): GeoJSON.Feature<GeoJSON.GeometryObject>;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a GeoJSON object or an array of GeoJSON objects.
|
||||
* Allows you to parse GeoJSON data and display it on the map. Extends FeatureGroup.
|
||||
@ -838,46 +883,6 @@ declare namespace L {
|
||||
*/
|
||||
setStyle(style: StyleFunction): this;
|
||||
|
||||
/**
|
||||
* Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer
|
||||
* and/or coordsToLatLng functions if provided as options.
|
||||
*/
|
||||
geometryToLayer(featureData: GeoJSON.Feature<GeoJSON.GeometryObject>, options?: GeoJSONOptions): Layer;
|
||||
|
||||
/**
|
||||
* Creates a LatLng object from an array of 2 numbers (longitude, latitude) or
|
||||
* 3 numbers (longitude, latitude, altitude) used in GeoJSON for points.
|
||||
*/
|
||||
coordsToLatLng(coords: [number, number]): LatLng;
|
||||
|
||||
coordsToLatLng(coords: [number, number, number]): LatLng;
|
||||
|
||||
/**
|
||||
* Creates a multidimensional array of LatLngs from a GeoJSON coordinates array.
|
||||
* levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of
|
||||
* arrays of points, etc., 0 by default).
|
||||
* Can use a custom coordsToLatLng function.
|
||||
*/
|
||||
coordsToLatLngs(coords: Array<number>, levelsDeep?: number, coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng): LatLng[]; // Not entirely sure how to define arbitrarily nested arrays
|
||||
|
||||
/**
|
||||
* Reverse of coordsToLatLng
|
||||
*/
|
||||
latLngToCoords(latlng: LatLng): [number, number] | [number, number, number];
|
||||
|
||||
/**
|
||||
* Reverse of coordsToLatLngs closed determines whether the first point should be
|
||||
* appended to the end of the array to close the feature, only used when levelsDeep is 0.
|
||||
* False by default.
|
||||
*/
|
||||
latLngsToCoords(latlngs: Array<LatLng>, levelsDeep?: number, closed?: boolean): [number, number] | [number, number, number];
|
||||
|
||||
/**
|
||||
* Normalize GeoJSON geometries/features into GeoJSON features.
|
||||
*/
|
||||
asFeature(geojson: GeoJSON.GeometryObject): GeoJSON.Feature<GeoJSON.GeometryObject>;
|
||||
|
||||
asFeature(geojson: GeoJSON.Feature<GeoJSON.GeometryObject>): GeoJSON.Feature<GeoJSON.GeometryObject>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -358,6 +358,18 @@ draggable.enable();
|
||||
draggable.disable();
|
||||
draggable.on('drag', () => {});
|
||||
|
||||
let twoCoords: [number, number] = [1, 2];
|
||||
latLng = L.GeoJSON.coordsToLatLng(twoCoords);
|
||||
let coords: number[] = L.GeoJSON.latLngToCoords(latLng);
|
||||
|
||||
let threeCoords: [number, number, number] = [1, 2, 3];
|
||||
latLng = L.GeoJSON.coordsToLatLng(threeCoords);
|
||||
coords = L.GeoJSON.latLngToCoords(latLng);
|
||||
|
||||
let nestedTwoCoords = [ [12, 13], [13, 14], [14, 15] ];
|
||||
let nestedLatLngs: L.LatLng[] = L.GeoJSON.coordsToLatLngs(nestedTwoCoords, 1);
|
||||
nestedTwoCoords = L.GeoJSON.latLngsToCoords(nestedLatLngs, 1);
|
||||
|
||||
class MyMarker extends L.Marker {
|
||||
constructor() {
|
||||
super([12, 13]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user