pub struct GoogleMap { /* private fields */ }Implementations§
Source§impl GoogleMap
impl GoogleMap
Sourcepub fn new<'a>(
center: impl Into<Location>,
zoom: u8,
apikey: impl Into<Option<&'a str>>,
) -> Self
pub fn new<'a>( center: impl Into<Location>, zoom: u8, apikey: impl Into<Option<&'a str>>, ) -> Self
Examples found in repository?
examples/google.rs (line 58)
4fn main() {
5 let netherlands = [
6 (53.3224787, 7.1852322),
7 (53.0056055, 7.1962228),
8 (52.6438557, 7.0463535),
9 (52.6447300, 6.7291260),
10 (52.4812789, 6.6894452),
11 (52.4342406, 7.0236950),
12 (52.2424500, 7.0470565),
13 (52.0470369, 6.6932297),
14 (51.9830783, 6.8290338),
15 (51.8964998, 6.7298075),
16 (51.8259113, 5.9564802),
17 (51.3774719, 6.2276121),
18 (51.0097412, 5.8965660),
19 (50.9158272, 6.0903844),
20 (50.7539195, 6.0194753),
21 (50.7542591, 5.6965799),
22 (50.8729117, 5.6644788),
23 (51.1726854, 5.8394065),
24 (51.2601708, 5.2948931),
25 (51.4591271, 5.0513089),
26 (51.4187846, 4.3904119),
27 (51.2176932, 3.8900991),
28 (51.3706174, 3.3641251),
29 ];
30
31 let switzerland = [
32 (47.5976076, 8.1243554),
33 (47.4744889, 7.0147812),
34 (46.0979767, 5.9697126),
35 (46.4142137, 6.5677645),
36 (45.8690191, 7.1026676),
37 (45.9015149, 7.8545345),
38 (46.4086133, 8.4121003),
39 (45.8274156, 9.0094792),
40 (46.4741242, 9.3507219),
41 (46.2297483, 10.157541),
42 (46.5731435, 10.068260),
43 (46.5810388, 10.496742),
44 (46.9718163, 10.414338),
45 (47.0381692, 9.6020123),
46 (47.5320018, 9.6006684),
47 (47.7892979, 8.5809824),
48 ];
49
50 let bern = [
51 (46.9666268, 7.1781895),
52 (47.1238637, 7.3361174),
53 (47.0593473, 7.6190164),
54 (46.8390079, 7.6863061),
55 (46.7638649, 7.3683927),
56 ];
57
58 let html = GoogleMap::new((49.7973, 5.4173), 6, None)
59 .draw(Marker::new((51.507, -0.127)).label("A").title("London"))
60 .draw(Marker::new((52.48, -1.902)).title("Birmingham"))
61 .draw(Polyline::new(netherlands).style(Color::Red))
62 .draw(Polygon::new(switzerland).path(bern).style(Color::Red))
63 .draw(
64 Rectangle::new((53.0833, 8.8), (51.3333, 12.3833))
65 .style(Color::Green)
66 .editable(true)
67 .draggable(true),
68 )
69 .draw(Circle::new((48.856, 2.352), 100_000.0).style(Color::HSL(200, 128, 100))) // Paris
70 .draw_all(switzerland.iter().step_by(4).map(Marker::new))
71 .draw(
72 Polyline::new([(0.0, 0.0), (1.0, 1.0)])
73 .geodesic(true)
74 .editable(true),
75 )
76 .to_string();
77
78 println!("{}", html);
79 fs::write("map.html", html).unwrap();
80
81 // // GoogleMap implements Display:
82 // let mut map = GoogleMap::new((49.817500, 15.473000), 8, MapType::Roadmap, None);
83 // map.marker(Marker::new(12.34, 45.67).label("home"));
84 // map.marker(Marker::new(12.34, 45.67).label("whatewer"));
85 // map.marker(Marker::new(12.34, 45.67).label("something"));
86 // println!("{}", map);
87}Sourcepub fn page_title(&mut self, value: impl AsRef<str>) -> &mut Self
pub fn page_title(&mut self, value: impl AsRef<str>) -> &mut Self
Set the title of the HTML page.
Sourcepub fn map_type(&mut self, value: MapType) -> &mut Self
pub fn map_type(&mut self, value: MapType) -> &mut Self
The initial map type. Defaults to MapType::Roadmap.
Sourcepub fn disable_default_gui(&mut self, value: bool) -> &mut Self
pub fn disable_default_gui(&mut self, value: bool) -> &mut Self
Enable/disable all default UI buttons.
Sourcepub fn disable_double_click_zoom(&mut self, value: bool) -> &mut Self
pub fn disable_double_click_zoom(&mut self, value: bool) -> &mut Self
Enable/disable zoom and center on double click. Enabled by default.
Sourcepub fn draw(&mut self, shape: impl Shape + 'static) -> &mut Self
pub fn draw(&mut self, shape: impl Shape + 'static) -> &mut Self
Draw a shape on the map.
Examples found in repository?
examples/google.rs (line 59)
4fn main() {
5 let netherlands = [
6 (53.3224787, 7.1852322),
7 (53.0056055, 7.1962228),
8 (52.6438557, 7.0463535),
9 (52.6447300, 6.7291260),
10 (52.4812789, 6.6894452),
11 (52.4342406, 7.0236950),
12 (52.2424500, 7.0470565),
13 (52.0470369, 6.6932297),
14 (51.9830783, 6.8290338),
15 (51.8964998, 6.7298075),
16 (51.8259113, 5.9564802),
17 (51.3774719, 6.2276121),
18 (51.0097412, 5.8965660),
19 (50.9158272, 6.0903844),
20 (50.7539195, 6.0194753),
21 (50.7542591, 5.6965799),
22 (50.8729117, 5.6644788),
23 (51.1726854, 5.8394065),
24 (51.2601708, 5.2948931),
25 (51.4591271, 5.0513089),
26 (51.4187846, 4.3904119),
27 (51.2176932, 3.8900991),
28 (51.3706174, 3.3641251),
29 ];
30
31 let switzerland = [
32 (47.5976076, 8.1243554),
33 (47.4744889, 7.0147812),
34 (46.0979767, 5.9697126),
35 (46.4142137, 6.5677645),
36 (45.8690191, 7.1026676),
37 (45.9015149, 7.8545345),
38 (46.4086133, 8.4121003),
39 (45.8274156, 9.0094792),
40 (46.4741242, 9.3507219),
41 (46.2297483, 10.157541),
42 (46.5731435, 10.068260),
43 (46.5810388, 10.496742),
44 (46.9718163, 10.414338),
45 (47.0381692, 9.6020123),
46 (47.5320018, 9.6006684),
47 (47.7892979, 8.5809824),
48 ];
49
50 let bern = [
51 (46.9666268, 7.1781895),
52 (47.1238637, 7.3361174),
53 (47.0593473, 7.6190164),
54 (46.8390079, 7.6863061),
55 (46.7638649, 7.3683927),
56 ];
57
58 let html = GoogleMap::new((49.7973, 5.4173), 6, None)
59 .draw(Marker::new((51.507, -0.127)).label("A").title("London"))
60 .draw(Marker::new((52.48, -1.902)).title("Birmingham"))
61 .draw(Polyline::new(netherlands).style(Color::Red))
62 .draw(Polygon::new(switzerland).path(bern).style(Color::Red))
63 .draw(
64 Rectangle::new((53.0833, 8.8), (51.3333, 12.3833))
65 .style(Color::Green)
66 .editable(true)
67 .draggable(true),
68 )
69 .draw(Circle::new((48.856, 2.352), 100_000.0).style(Color::HSL(200, 128, 100))) // Paris
70 .draw_all(switzerland.iter().step_by(4).map(Marker::new))
71 .draw(
72 Polyline::new([(0.0, 0.0), (1.0, 1.0)])
73 .geodesic(true)
74 .editable(true),
75 )
76 .to_string();
77
78 println!("{}", html);
79 fs::write("map.html", html).unwrap();
80
81 // // GoogleMap implements Display:
82 // let mut map = GoogleMap::new((49.817500, 15.473000), 8, MapType::Roadmap, None);
83 // map.marker(Marker::new(12.34, 45.67).label("home"));
84 // map.marker(Marker::new(12.34, 45.67).label("whatewer"));
85 // map.marker(Marker::new(12.34, 45.67).label("something"));
86 // println!("{}", map);
87}Sourcepub fn draw_all(
&mut self,
shapes: impl IntoIterator<Item = impl Shape + 'static>,
) -> &mut Self
pub fn draw_all( &mut self, shapes: impl IntoIterator<Item = impl Shape + 'static>, ) -> &mut Self
Draw multiple shapes at once.
Examples found in repository?
examples/google.rs (line 70)
4fn main() {
5 let netherlands = [
6 (53.3224787, 7.1852322),
7 (53.0056055, 7.1962228),
8 (52.6438557, 7.0463535),
9 (52.6447300, 6.7291260),
10 (52.4812789, 6.6894452),
11 (52.4342406, 7.0236950),
12 (52.2424500, 7.0470565),
13 (52.0470369, 6.6932297),
14 (51.9830783, 6.8290338),
15 (51.8964998, 6.7298075),
16 (51.8259113, 5.9564802),
17 (51.3774719, 6.2276121),
18 (51.0097412, 5.8965660),
19 (50.9158272, 6.0903844),
20 (50.7539195, 6.0194753),
21 (50.7542591, 5.6965799),
22 (50.8729117, 5.6644788),
23 (51.1726854, 5.8394065),
24 (51.2601708, 5.2948931),
25 (51.4591271, 5.0513089),
26 (51.4187846, 4.3904119),
27 (51.2176932, 3.8900991),
28 (51.3706174, 3.3641251),
29 ];
30
31 let switzerland = [
32 (47.5976076, 8.1243554),
33 (47.4744889, 7.0147812),
34 (46.0979767, 5.9697126),
35 (46.4142137, 6.5677645),
36 (45.8690191, 7.1026676),
37 (45.9015149, 7.8545345),
38 (46.4086133, 8.4121003),
39 (45.8274156, 9.0094792),
40 (46.4741242, 9.3507219),
41 (46.2297483, 10.157541),
42 (46.5731435, 10.068260),
43 (46.5810388, 10.496742),
44 (46.9718163, 10.414338),
45 (47.0381692, 9.6020123),
46 (47.5320018, 9.6006684),
47 (47.7892979, 8.5809824),
48 ];
49
50 let bern = [
51 (46.9666268, 7.1781895),
52 (47.1238637, 7.3361174),
53 (47.0593473, 7.6190164),
54 (46.8390079, 7.6863061),
55 (46.7638649, 7.3683927),
56 ];
57
58 let html = GoogleMap::new((49.7973, 5.4173), 6, None)
59 .draw(Marker::new((51.507, -0.127)).label("A").title("London"))
60 .draw(Marker::new((52.48, -1.902)).title("Birmingham"))
61 .draw(Polyline::new(netherlands).style(Color::Red))
62 .draw(Polygon::new(switzerland).path(bern).style(Color::Red))
63 .draw(
64 Rectangle::new((53.0833, 8.8), (51.3333, 12.3833))
65 .style(Color::Green)
66 .editable(true)
67 .draggable(true),
68 )
69 .draw(Circle::new((48.856, 2.352), 100_000.0).style(Color::HSL(200, 128, 100))) // Paris
70 .draw_all(switzerland.iter().step_by(4).map(Marker::new))
71 .draw(
72 Polyline::new([(0.0, 0.0), (1.0, 1.0)])
73 .geodesic(true)
74 .editable(true),
75 )
76 .to_string();
77
78 println!("{}", html);
79 fs::write("map.html", html).unwrap();
80
81 // // GoogleMap implements Display:
82 // let mut map = GoogleMap::new((49.817500, 15.473000), 8, MapType::Roadmap, None);
83 // map.marker(Marker::new(12.34, 45.67).label("home"));
84 // map.marker(Marker::new(12.34, 45.67).label("whatewer"));
85 // map.marker(Marker::new(12.34, 45.67).label("something"));
86 // println!("{}", map);
87}Trait Implementations§
Auto Trait Implementations§
impl Freeze for GoogleMap
impl !RefUnwindSafe for GoogleMap
impl !Send for GoogleMap
impl !Sync for GoogleMap
impl Unpin for GoogleMap
impl !UnwindSafe for GoogleMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more