Skip to content

Commit 492a7ba

Browse files
authored
🤖 Merge PR DefinitelyTyped#73534 feat(plotly.js): add MapboxBounds, supplement jsdoc for Mapbox by @hkleungai
1 parent b43b29d commit 492a7ba

File tree

4 files changed

+120
-2
lines changed

4 files changed

+120
-2
lines changed

‎types/plotly.js/index.d.ts‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,63 @@ export interface MapboxLayers {
195195
name: string;
196196
templateitemname: string;
197197
}
198+
199+
export interface MapboxBounds {
200+
/**
201+
* Sets the maximum longitude of the map (in degrees East) if `west`, `south` and `north` are declared.
202+
*/
203+
east: number;
204+
/**
205+
* Sets the maximum latitude of the map (in degrees North) if `east`, `west` and `south` are declared.
206+
*/
207+
north: number;
208+
/**
209+
* Sets the minimum latitude of the map (in degrees North) if `east`, `west` and `north` are declared.
210+
*/
211+
south: number;
212+
/**
213+
* Sets the minimum longitude of the map (in degrees East) if `east`, `south` and `north` are declared.
214+
*/
215+
west: number;
216+
}
217+
198218
export interface Mapbox {
199219
domain: Partial<Domain>;
220+
/**
221+
* Sets the mapbox access token to be used for this mapbox map.
222+
* Alternatively, the mapbox access token can be set in the configuration options under `mapboxAccessToken`.
223+
* Note that accessToken are only required when `style` (e.g with values : basic, streets, outdoors, light, dark, satellite, satellite-streets ) and/or a layout layer references the Mapbox server.
224+
*/
200225
accesstoken: string;
226+
/**
227+
* Defines the map layers that are rendered by default below the trace layers defined in `data`, which are themselves by default rendered below the layers defined in `layout.mapbox.layers`.
228+
* These layers can be defined either explicitly as a Mapbox Style object which can contain multiple layer definitions that load data from any public or private Tile Map Service (TMS or XYZ) or Web Map Service (WMS) or implicitly by using one of the built-in style objects which use WMSes which do not require any access tokens, or by using a default Mapbox style or custom Mapbox style URL, both of which require a Mapbox access token.
229+
* Note that Mapbox access token can be set in the `accesstoken` attribute or in the `mapboxAccessToken` config option.
230+
* Mapbox Style objects are of the form described in the Mapbox GL JS documentation available at https://docs.mapbox.com/mapbox-gl-js/style-spec.
231+
* The built-in plotly.js styles objects are: carto-darkmatter, carto-positron, open-street-map, stamen-terrain, stamen-toner, stamen-watercolor, white-bg.
232+
* The built-in Mapbox styles are: basic, streets, outdoors, light, dark, satellite, satellite-streets.
233+
* Mapbox style URLs are of the form: mapbox://mapbox.mapbox-<name>-<version>
234+
*/
201235
style: number | string;
202236
center: Partial<MapboxCenter>;
237+
/**
238+
* Sets the zoom level of the map (mapbox.zoom).
239+
*/
203240
zoom: number;
241+
/**
242+
* Sets the bearing angle of the map in degrees counter-clockwise from North (mapbox.bearing).
243+
*/
204244
bearing: number;
245+
bounds: MapboxBounds;
246+
/**
247+
* Sets the pitch angle of the map (in degrees, where *0* means perpendicular to the surface of the map) (mapbox.pitch).
248+
*/
205249
pitch: number;
206250
layers: Array<Partial<MapboxLayers>>;
251+
/**
252+
* Controls persistence of user-driven changes in the view: `center`, `zoom`, `bearing`, `pitch`.
253+
* Defaults to `layout.uirevision`.
254+
*/
207255
uirevision: number | string;
208256
uid: string;
209257
}

‎types/plotly.js/test/index-tests.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,18 @@ function rand() {
12321232

12331233
const layout: Partial<Layout> = {
12341234
dragmode: "zoom",
1235-
mapbox: { style: "open-street-map", center: { lat: 0, lon: -0 }, zoom: 3 },
1235+
mapbox: {
1236+
accesstoken: "accesstoken",
1237+
domain: { x: [0], y: [0], row: 0, column: 0 },
1238+
style: "open-street-map",
1239+
center: { lat: 0, lon: -0 },
1240+
zoom: 3,
1241+
bearing: 30,
1242+
bounds: { east: 0, west: 0, south: 0, north: 0 },
1243+
pitch: 0,
1244+
layers: [],
1245+
uirevision: "uirevision",
1246+
},
12361247
margin: { r: 0, t: 0, b: 0, l: 0 },
12371248
};
12381249

‎types/plotly.js/v2/index.d.ts‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,63 @@ export interface MapboxLayers {
195195
name: string;
196196
templateitemname: string;
197197
}
198+
199+
export interface MapboxBounds {
200+
/**
201+
* Sets the maximum longitude of the map (in degrees East) if `west`, `south` and `north` are declared.
202+
*/
203+
east: number;
204+
/**
205+
* Sets the maximum latitude of the map (in degrees North) if `east`, `west` and `south` are declared.
206+
*/
207+
north: number;
208+
/**
209+
* Sets the minimum latitude of the map (in degrees North) if `east`, `west` and `north` are declared.
210+
*/
211+
south: number;
212+
/**
213+
* Sets the minimum longitude of the map (in degrees East) if `east`, `south` and `north` are declared.
214+
*/
215+
west: number;
216+
}
217+
198218
export interface Mapbox {
199219
domain: Partial<Domain>;
220+
/**
221+
* Sets the mapbox access token to be used for this mapbox map.
222+
* Alternatively, the mapbox access token can be set in the configuration options under `mapboxAccessToken`.
223+
* Note that accessToken are only required when `style` (e.g with values : basic, streets, outdoors, light, dark, satellite, satellite-streets ) and/or a layout layer references the Mapbox server.
224+
*/
200225
accesstoken: string;
226+
/**
227+
* Defines the map layers that are rendered by default below the trace layers defined in `data`, which are themselves by default rendered below the layers defined in `layout.mapbox.layers`.
228+
* These layers can be defined either explicitly as a Mapbox Style object which can contain multiple layer definitions that load data from any public or private Tile Map Service (TMS or XYZ) or Web Map Service (WMS) or implicitly by using one of the built-in style objects which use WMSes which do not require any access tokens, or by using a default Mapbox style or custom Mapbox style URL, both of which require a Mapbox access token.
229+
* Note that Mapbox access token can be set in the `accesstoken` attribute or in the `mapboxAccessToken` config option.
230+
* Mapbox Style objects are of the form described in the Mapbox GL JS documentation available at https://docs.mapbox.com/mapbox-gl-js/style-spec.
231+
* The built-in plotly.js styles objects are: carto-darkmatter, carto-positron, open-street-map, stamen-terrain, stamen-toner, stamen-watercolor, white-bg.
232+
* The built-in Mapbox styles are: basic, streets, outdoors, light, dark, satellite, satellite-streets.
233+
* Mapbox style URLs are of the form: mapbox://mapbox.mapbox-<name>-<version>
234+
*/
201235
style: number | string;
202236
center: Partial<MapboxCenter>;
237+
/**
238+
* Sets the zoom level of the map (mapbox.zoom).
239+
*/
203240
zoom: number;
241+
/**
242+
* Sets the bearing angle of the map in degrees counter-clockwise from North (mapbox.bearing).
243+
*/
204244
bearing: number;
245+
bounds: MapboxBounds;
246+
/**
247+
* Sets the pitch angle of the map (in degrees, where *0* means perpendicular to the surface of the map) (mapbox.pitch).
248+
*/
205249
pitch: number;
206250
layers: Array<Partial<MapboxLayers>>;
251+
/**
252+
* Controls persistence of user-driven changes in the view: `center`, `zoom`, `bearing`, `pitch`.
253+
* Defaults to `layout.uirevision`.
254+
*/
207255
uirevision: number | string;
208256
uid: string;
209257
}

‎types/plotly.js/v2/test/index-tests.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,18 @@ function rand() {
12371237

12381238
const layout: Partial<Layout> = {
12391239
dragmode: "zoom",
1240-
mapbox: { style: "open-street-map", center: { lat: 0, lon: -0 }, zoom: 3 },
1240+
mapbox: {
1241+
accesstoken: "accesstoken",
1242+
domain: { x: [0], y: [0], row: 0, column: 0 },
1243+
style: "open-street-map",
1244+
center: { lat: 0, lon: -0 },
1245+
zoom: 3,
1246+
bearing: 30,
1247+
bounds: { east: 0, west: 0, south: 0, north: 0 },
1248+
pitch: 0,
1249+
layers: [],
1250+
uirevision: "uirevision",
1251+
},
12411252
margin: { r: 0, t: 0, b: 0, l: 0 },
12421253
};
12431254

0 commit comments

Comments
 (0)