Skip to content

Commit 046e3c4

Browse files
committed
plotlyjs v2.16: Add bounds to mapbox subplots (plotly/plotly.js#6339)
1 parent f3c053b commit 046e3c4

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

src/Plotly.NET/Layout/ObjectAbstractions/Map/Mapbox.fs

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type Mapbox() =
1616
/// <param name="Domain">Sets the domain of the Mapbox subplot</param>
1717
/// <param name="AccessToken">Sets the mapbox access token to be used for this mapbox map. Alternatively, the mapbox access token can be set in the configuration options under `mapboxAccessToken`. 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.</param>
1818
/// <param name="Style">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`. 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 Note that Mapbox access token can be set in the `accesstoken` attribute or in the `mapboxAccessToken` config option. 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 The built-in plotly.js styles objects are: carto-darkmatter, carto-positron, open-street-map, stamen-terrain, stamen-toner, stamen-watercolor, white-bg The built-in Mapbox styles are: basic, streets, outdoors, light, dark, satellite, satellite-streets Mapbox style URLs are of the form: mapbox://mapbox.mapbox/name/version</param>
19+
/// <param name="Bounds">Sets the bounds of the map</param>
1920
/// <param name="Center">Sets the (lon,lat) coordinates of the center of the map view</param>
2021
/// <param name="Zoom">Sets the zoom level of the map (mapbox.zoom).</param>
2122
/// <param name="Bearing">Sets the bearing angle of the map in degrees counter-clockwise from North (mapbox.bearing).</param>
@@ -26,6 +27,7 @@ type Mapbox() =
2627
[<Optional; DefaultParameterValue(null)>] ?Domain: Domain,
2728
[<Optional; DefaultParameterValue(null)>] ?AccessToken: string,
2829
[<Optional; DefaultParameterValue(null)>] ?Style: StyleParam.MapboxStyle,
30+
[<Optional; DefaultParameterValue(null)>] ?Bounds: MapboxBounds,
2931
[<Optional; DefaultParameterValue(null)>] ?Center: (float * float),
3032
[<Optional; DefaultParameterValue(null)>] ?Zoom: float,
3133
[<Optional; DefaultParameterValue(null)>] ?Bearing: float,
@@ -37,6 +39,7 @@ type Mapbox() =
3739
?Domain = Domain,
3840
?AccessToken = AccessToken,
3941
?Style = Style,
42+
?Bounds = Bounds,
4043
?Center = Center,
4144
?Zoom = Zoom,
4245
?Bearing = Bearing,
@@ -48,6 +51,7 @@ type Mapbox() =
4851
/// <param name="Domain">Sets the domain of the Mapbox subplot</param>
4952
/// <param name="AccessToken">Sets the mapbox access token to be used for this mapbox map. Alternatively, the mapbox access token can be set in the configuration options under `mapboxAccessToken`. 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.</param>
5053
/// <param name="Style">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`. 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 Note that Mapbox access token can be set in the `accesstoken` attribute or in the `mapboxAccessToken` config option. 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 The built-in plotly.js styles objects are: carto-darkmatter, carto-positron, open-street-map, stamen-terrain, stamen-toner, stamen-watercolor, white-bg The built-in Mapbox styles are: basic, streets, outdoors, light, dark, satellite, satellite-streets Mapbox style URLs are of the form: mapbox://mapbox.mapbox/name/version</param>
54+
/// <param name="Bounds">Sets the bounds of the map</param>
5155
/// <param name="Center">Sets the (lon,lat) coordinates of the center of the map view</param>
5256
/// <param name="Zoom">Sets the zoom level of the map (mapbox.zoom).</param>
5357
/// <param name="Bearing">Sets the bearing angle of the map in degrees counter-clockwise from North (mapbox.bearing).</param>
@@ -58,6 +62,7 @@ type Mapbox() =
5862
[<Optional; DefaultParameterValue(null)>] ?Domain: Domain,
5963
[<Optional; DefaultParameterValue(null)>] ?AccessToken: string,
6064
[<Optional; DefaultParameterValue(null)>] ?Style: StyleParam.MapboxStyle,
65+
[<Optional; DefaultParameterValue(null)>] ?Bounds: MapboxBounds,
6166
[<Optional; DefaultParameterValue(null)>] ?Center: (float * float),
6267
[<Optional; DefaultParameterValue(null)>] ?Zoom: float,
6368
[<Optional; DefaultParameterValue(null)>] ?Bearing: float,
@@ -69,7 +74,7 @@ type Mapbox() =
6974
Domain |> DynObj.setValueOpt mapBox "domain"
7075
AccessToken |> DynObj.setValueOpt mapBox "accesstoken"
7176
Style |> DynObj.setValueOptBy mapBox "style" StyleParam.MapboxStyle.convert
72-
77+
Bounds |> DynObj.setValueOpt mapBox "bounds"
7378
Center
7479
|> Option.map (fun (lon, lat) ->
7580
let t = DynamicObj()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
namespace Plotly.NET.LayoutObjects
2+
3+
open Plotly.NET
4+
open DynamicObj
5+
open System
6+
open System.Runtime.InteropServices
7+
8+
/// <summary></summary>
9+
type MapboxBounds() =
10+
11+
inherit DynamicObj()
12+
13+
/// <summary>
14+
/// Returns a new MapboxBounds object with the given styles
15+
/// </summary>
16+
/// <param name="East">Sets the maximum longitude of the map (in degrees East) if `west`, `south` and `north` are declared.</param>
17+
/// <param name="North">Sets the maximum latitude of the map (in degrees North) if `east`, `west` and `south` are declared.</param>
18+
/// <param name="South">Sets the minimum latitude of the map (in degrees North) if `east`, `west` and `north` are declared.</param>
19+
/// <param name="West">Sets the minimum latitude of the map (in degrees North) if `east`, `west` and `north` are declared.</param>
20+
static member init
21+
(
22+
[<Optional; DefaultParameterValue(null)>] ?East: float,
23+
[<Optional; DefaultParameterValue(null)>] ?North: float,
24+
[<Optional; DefaultParameterValue(null)>] ?South: float,
25+
[<Optional; DefaultParameterValue(null)>] ?West: float
26+
) =
27+
MapboxBounds()
28+
|> MapboxBounds.style (
29+
?East = East,
30+
?North = North,
31+
?South = South,
32+
?West = West
33+
)
34+
35+
/// <summary>
36+
/// Returns a function that applies the given styles to a MapoxBounds object.
37+
/// </summary>
38+
/// <param name="East">Sets the maximum longitude of the map (in degrees East) if `west`, `south` and `north` are declared.</param>
39+
/// <param name="North">Sets the maximum latitude of the map (in degrees North) if `east`, `west` and `south` are declared.</param>
40+
/// <param name="South">Sets the minimum latitude of the map (in degrees North) if `east`, `west` and `north` are declared.</param>
41+
/// <param name="West">Sets the minimum latitude of the map (in degrees North) if `east`, `west` and `north` are declared.</param>
42+
static member style
43+
(
44+
[<Optional; DefaultParameterValue(null)>] ?East: float,
45+
[<Optional; DefaultParameterValue(null)>] ?North: float,
46+
[<Optional; DefaultParameterValue(null)>] ?South: float,
47+
[<Optional; DefaultParameterValue(null)>] ?West: float
48+
) =
49+
(fun (mapboxBounds: MapboxBounds) ->
50+
51+
East |> DynObj.setValueOpt mapboxBounds "east"
52+
North |> DynObj.setValueOpt mapboxBounds "north"
53+
South |> DynObj.setValueOpt mapboxBounds "south"
54+
West |> DynObj.setValueOpt mapboxBounds "west"
55+
56+
mapboxBounds)

src/Plotly.NET/Plotly.NET.fsproj

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
<Compile Include="Layout\ObjectAbstractions\Map\MapboxLayerSymbol.fs" />
8181
<Compile Include="Layout\ObjectAbstractions\Map\MapboxLayer.fs" />
8282
<Compile Include="Layout\ObjectAbstractions\Map\MapboxCluster.fs" />
83+
<Compile Include="Layout\ObjectAbstractions\Map\MapboxBounds.fs" />
8384
<Compile Include="Layout\ObjectAbstractions\Map\Mapbox.fs" />
8485
<Compile Include="Layout\ObjectAbstractions\Ternary\Ternary.fs" />
8586
<Compile Include="Layout\ObjectAbstractions\3D\Camera.fs" />

0 commit comments

Comments
 (0)