2个版本
使用旧的Rust 2015
0.0.3 | 2017年7月4日 |
---|---|
0.0.2 | 2017年6月17日 |
#264 in 地理空间
22KB
471 行
bingmaps-rs
Rust API绑定,用于Bing Maps v1 HTTP API。
绑定当前支持
- 通过搜索查询进行地理编码
- 通过纬度/经度进行地理编码
用法
在您的 Cargo.toml
中添加以下内容
[dependencies]
bingmaps = "0.0.3"
并在您的crate根目录中添加以下内容
extern crate bingmaps;
示例
use bingmaps;
use bingmaps::locations::{Location, FindPoint, EntityType, Confidence, MatchCode};
use std::env;
let key = env::var("BING_MAPS_KEY").unwrap();
let client = bingmaps::Client::new();
// Find a Location by search-term / query
let locations = Location::find_by_query(&client, "Times Square, New York", None).unwrap();
// Find a Location by Lat/Lng values OR from text (eg. FindPoint::from_str("40.75890,-73.98516");)
let params = FindPoint::from_latlng(40.758903, -73.985163);
let locations = Location::find_by_point(&client, params, None).unwrap();
println!("{:#?}", locations.next().unwrap());
/*
Location {
name: "1551 7th Ave, New York, NY 10036",
point: Point {coordinates: [40.75891, -73.98546]},
bbox: [40.75504728242933, -73.9922589957156, 40.76277271757068, -73.9786610042844],
entity_type: Address,
address: Address {
address_line: Some("1551 7th Ave"),
neighborhood: None,
locality: Some("New York"),
postal_code: Some("10036"),
admin_district1: Some("NY"),
admin_district2: Some("New York Co."),
country: Some("United States"),
country_iso: None,
landmark: None,
formatted: Some("1551 7th Ave, New York, NY 10036"),
},
confidence: High,
match_codes: [Good],
}
依赖关系
~7–16MB
~234K SLoC