Skip to content
Merged
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
94 changes: 43 additions & 51 deletions examples/maps/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,26 @@
use plotly::{
color::Rgb,
common::{Line, Marker, Mode},
layout::{
Axis, Center, DragMode, LayoutGeo, Mapbox, MapboxStyle, Margin, Projection, Rotation,
},
DensityMapbox, Layout, Plot, ScatterGeo, ScatterMapbox,
layout::{Axis, Center, DragMode, LayoutGeo, Mapbox, MapboxStyle, Projection, Rotation},
Configuration, DensityMapbox, Layout, Plot, ScatterGeo, ScatterMapbox,
};
use plotly_utils::write_example_to_html;

fn scatter_mapbox(show: bool, file_name: &str) {
let trace = ScatterMapbox::new(vec![45.5017], vec![-73.5673])
.marker(Marker::new().size(25).opacity(0.9));

let layout = Layout::new()
.drag_mode(DragMode::Zoom)
.margin(Margin::new().top(0).left(0).bottom(0).right(0))
.mapbox(
Mapbox::new()
.style(MapboxStyle::OpenStreetMap)
.center(Center::new(45.5017, -73.5673))
.zoom(5),
);
let layout = Layout::new().drag_mode(DragMode::Zoom).mapbox(
Mapbox::new()
.style(MapboxStyle::OpenStreetMap)
.center(Center::new(45.5017, -73.5673))
.zoom(5),
);

let mut plot = Plot::new();
plot.add_trace(trace);
plot.set_layout(layout);
plot.set_configuration(Configuration::default().responsive(true).fill_frame(true));

let path = write_example_to_html(&plot, file_name);
if show {
Expand Down Expand Up @@ -100,35 +96,33 @@ fn scatter_geo(show: bool, file_name: &str) {
plot.add_trace(trace);
}

let layout = Layout::new()
.drag_mode(DragMode::Zoom)
.margin(Margin::new().top(0).left(0).bottom(0).right(0))
.geo(
LayoutGeo::new()
.showocean(true)
.showlakes(true)
.showcountries(true)
.showland(true)
.oceancolor(Rgb::new(0, 255, 255))
.lakecolor(Rgb::new(0, 255, 255))
.landcolor(Rgb::new(230, 145, 56))
.lataxis(
Axis::new()
.show_grid(true)
.grid_color(Rgb::new(102, 102, 102)),
)
.lonaxis(
Axis::new()
.show_grid(true)
.grid_color(Rgb::new(102, 102, 102)),
)
.projection(
Projection::new()
.projection_type(plotly::layout::ProjectionType::Orthographic)
.rotation(Rotation::new().lon(-100.0).lat(40.0)),
),
);

let layout = Layout::new().drag_mode(DragMode::Zoom).geo(
LayoutGeo::new()
.showocean(true)
.showlakes(true)
.showcountries(true)
.showland(true)
.oceancolor(Rgb::new(0, 255, 255))
.lakecolor(Rgb::new(0, 255, 255))
.landcolor(Rgb::new(230, 145, 56))
.lataxis(
Axis::new()
.show_grid(true)
.grid_color(Rgb::new(102, 102, 102)),
)
.lonaxis(
Axis::new()
.show_grid(true)
.grid_color(Rgb::new(102, 102, 102)),
)
.projection(
Projection::new()
.projection_type(plotly::layout::ProjectionType::Orthographic)
.rotation(Rotation::new().lon(-100.0).lat(40.0)),
),
);

plot.set_configuration(Configuration::default().responsive(true).fill_frame(true));
plot.set_layout(layout);

let path = write_example_to_html(&plot, file_name);
Expand All @@ -140,19 +134,17 @@ fn scatter_geo(show: bool, file_name: &str) {
fn density_mapbox(show: bool, file_name: &str) {
let trace = DensityMapbox::new(vec![45.5017], vec![-73.5673], vec![0.75]).zauto(true);

let layout = Layout::new()
.drag_mode(DragMode::Zoom)
.margin(Margin::new().top(0).left(0).bottom(0).right(0))
.mapbox(
Mapbox::new()
.style(MapboxStyle::OpenStreetMap)
.center(Center::new(45.5017, -73.5673))
.zoom(5),
);
let layout = Layout::new().drag_mode(DragMode::Zoom).mapbox(
Mapbox::new()
.style(MapboxStyle::OpenStreetMap)
.center(Center::new(45.5017, -73.5673))
.zoom(5),
);

let mut plot = Plot::new();
plot.add_trace(trace);
plot.set_layout(layout);
plot.set_configuration(Configuration::default().responsive(true).fill_frame(true));

let path = write_example_to_html(&plot, file_name);
if show {
Expand Down
Loading