YY. GeoJSON
GeoJSON 反序列化工具, GeoJSON SPEC
creation
constructor()
example
js
let json = {
"type": "Feature",
"properties": {
"name": "北京"
},
"geometry": {
"type": "Point",
"coordinates": [116.3671875, 39.977120098439634]
}
let point = YY.GeoJSON.toGeometry(json);
vectorLayer.addOverlay(point);
let json = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
128.34228515625,
44.574817404670306
],
[
131.19873046875,
44.465151013519616
],
[
131.06689453125,
42.88401467044253
],
[
132.967529296875,
42.374778361114195
]
]
}
}
let line = YY.GeoJSON.toGeometry(json);
vectorLayer.addOverlay(line);
method
TIP
static 表示静态方法, 即对象直接访问, 无需new
static
toGeometry(json, fn)
- 将 geojson 序列化成 OverLayer 对象
- 参数
- {Object}
json
: geojson - {function}
fn
: 回调函数
- {Object}
- 返回值: YY. Overlay||Array[YY. Overlay]
static
get(url, fn)
- ajax 获取 geojson 数据
- 参数
- {String}
url
: geojson url - {function}
fn
: 回调函数
- {String}
- 返回值: