Crates.io | mapplot |
lib.rs | mapplot |
version | 0.1.0 |
source | src |
created_at | 2023-02-19 19:39:34.593116 |
updated_at | 2023-02-19 19:39:34.593116 |
description | A library for plotting data on maps. |
homepage | |
repository | https://github.com/ondt/mapplot |
max_upload_size | |
id | 789233 |
size | 33,581 |
mapplot
- A map plotter library for Rustmapplot is a Rust library for plotting data on maps.
mapplot::google
- Generates an HTML file that uses the
Google Maps JavaScript API to display map data.use std::fs;
use mapplot::google::{Circle, GoogleMap, Marker, Polygon, Polyline, Rectangle, style::Color};
fn main() {
let netherlands = [
(53.3224787, 7.1852322),
(53.0056055, 7.1962228),
// --snip--
(51.2176932, 3.8900991),
(51.3706174, 3.3641251),
];
let switzerland = [
(47.5976076, 8.1243554),
(47.4744889, 7.0147812),
// --snip--
(47.5320018, 9.6006684),
(47.7892979, 8.5809824),
];
let bern = [
(46.9666268, 7.1781895),
(47.1238637, 7.3361174),
(47.0593473, 7.6190164),
(46.8390079, 7.6863061),
(46.7638649, 7.3683927),
];
let html = GoogleMap::new((49.7973, 5.4173), 6, "<your-apikey-here>")
.draw(Marker::new((51.507, -0.127)).label("A").title("London"))
.draw(Marker::new((52.48, -1.902)).title("Birmingham"))
.draw(Polyline::new(netherlands).style(Color::Red))
.draw(Polygon::new(switzerland).path(bern).style(Color::Red))
.draw(Rectangle::new((53.0833, 8.8), (51.3333, 12.3833)).style(Color::Green).editable(true).draggable(true))
.draw(Circle::new((48.856, 2.352), 100_000.0).style(Color::HSL(200, 128, 100))) // Paris
.to_string();
fs::write("map.html", html).unwrap();
}