Skip to content

Commit eecf69c

Browse files
G0rocksandrei-ng
authored andcommitted
Got as far as I can with implementing ScatterGeo but still not working properly. Always uses the same projection and I don't know why. Need some help with this.
1 parent 4295422 commit eecf69c

File tree

1 file changed

+35
-38
lines changed

1 file changed

+35
-38
lines changed

plotly/src/layout/mod.rs

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,48 +1453,33 @@ impl Mapbox {
14531453
}
14541454
}
14551455

1456-
#[derive(Serialize, Clone, Debug)]
1457-
#[serde(rename_all = "kebab-case")]
1458-
pub enum MapboxStyle {
1459-
#[serde(rename = "carto-darkmatter")]
1460-
CartoDarkMatter,
1461-
CartoPositron,
1462-
OpenStreetMap,
1463-
StamenTerrain,
1464-
StamenToner,
1465-
StamenWatercolor,
1466-
WhiteBg,
1467-
Basic,
1468-
Streets,
1469-
Outdoors,
1470-
Light,
1471-
Dark,
1472-
Satellite,
1473-
SatelliteStreets,
1474-
}
1475-
14761456
#[derive(Serialize, Clone, Debug, FieldSetter)]
14771457
pub struct Geo {
1478-
/// Sets the geo access token to be used for this geo map. Note that
1479-
/// `access_token`s are only required when `style` (e.g with values: basic,
1480-
/// streets, outdoors, light, dark, satellite, satellite-streets)
1481-
/// and/or a layout layer references the Mapbox server.
1482-
#[serde(rename = "accesstoken")]
1483-
access_token: Option<String>,
1484-
/// Sets the bearing angle of the map in degrees counter-clockwise from
1485-
/// North.
1486-
bearing: Option<f64>,
1487-
/// Sets the latitude and longitude of the center of the map.
1488-
center: Option<Center>,
1489-
/// Sets the domain within which the mapbox will be drawn.
1490-
domain: Option<Domain>,
1491-
/// Sets the pitch angle of the map in degrees, where `0` means
1492-
/// perpendicular to the surface of the map.
1493-
pitch: Option<f64>,
1494-
/// Sets the style of the map.
1495-
style: Option<MapboxStyle>,
14961458
/// Sets the zoom level of the map.
14971459
zoom: Option<u8>,
1460+
/// Sets the projection of the map
1461+
#[field_setter(default = "Projection::new().projection_type(ProjectionType::Orthographic)")]
1462+
projection: Option<Projection>,
1463+
/// If to show the ocean or not
1464+
#[field_setter(default = "Some(true)")]
1465+
showocean: Option<bool>,
1466+
/// Sets the color of the ocean
1467+
#[field_setter(default = "'rgb(0, 255, 255)'")]
1468+
oceancolor: Option<Box<dyn Color>>,
1469+
/// If to show the land or not
1470+
showland: Option<bool>,
1471+
/// Sets the color of the land
1472+
landcolor: Option<Box<dyn Color>>,
1473+
/// If to show lakes or not
1474+
showlakes: Option<bool>,
1475+
/// Sets the color of the lakes
1476+
lakecolor: Option<Box<dyn Color>>,
1477+
/// If to show countries (borders) or not
1478+
showcountries: Option<bool>,
1479+
/// Configures the longitude axis
1480+
lonaxis: Option<Axis>,
1481+
/// Configures the latitude axis
1482+
lataxis: Option<Axis>,
14981483
}
14991484

15001485
impl Geo {
@@ -1600,10 +1585,21 @@ pub enum ProjectionType {
16001585
Orthographic,
16011586
}
16021587

1588+
/// Defines the rotation of the projection in degrees.
1589+
/// The rotation is defined by the longitude and latitude
1590+
/// of the center of the projection.
1591+
/// https://plotly.com/javascript/lines-on-maps/
1592+
#[derive(Serialize, Debug, Clone)]
1593+
pub struct ProjectionRotation {
1594+
lon: f64,
1595+
lat: f64,
1596+
}
1597+
16031598
impl From<ProjectionType> for Projection {
16041599
fn from(projection_type: ProjectionType) -> Self {
16051600
Projection {
16061601
projection_type: Some(projection_type),
1602+
rotation: None,
16071603
}
16081604
}
16091605
}
@@ -1614,6 +1610,7 @@ impl From<ProjectionType> for Projection {
16141610
pub struct Projection {
16151611
#[serde(rename = "type")]
16161612
projection_type: Option<ProjectionType>,
1613+
rotation: Option<ProjectionRotation>,
16171614
}
16181615

16191616
impl Projection {

0 commit comments

Comments
 (0)