Static Methods
(static) toGeometry(geoJSON, foreachFnopt) [source]
Convert one or more GeoJSON objects to geometry
var collection = {
"type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
"properties": {"prop0": "value0"}
},
{ "type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
]
},
"properties": {
"prop0": "value0",
"prop1": 0.0
}
},
{ "type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
[100.0, 1.0], [100.0, 0.0] ]
]
},
"properties": {
"prop0": "value0",
"prop1": {"this": "that"}
}
}
]
}
// A geometry array.
const geometries = GeoJSON.toGeometry(collection, geometry => { geometry.config('draggable', true); });
Parameter | Type | Description |
---|---|---|
geoJSON
|
String | Object | Array.<Object> | GeoJSON objects or GeoJSON string |
foreachFn
opt
|
function | callback function for each geometry |
Returns:
Geometry|Array.<Geometry>: a geometry array when input is a FeatureCollection(static) toGeometryAsync(geoJSON, foreachFnopt, countPerTimeopt) [source]
async Convert one or more GeoJSON objects to geometry
GeoJSON.toGeometryAsync(geoJSON).then(geos=>{
console.log(geos);
})
Parameter | Type | Default | Description |
---|---|---|---|
geoJSON
|
String | Object | Array.<Object> | GeoJSON objects or GeoJSON string | |
foreachFn
opt
|
function | callback function for each geometry | |
countPerTime
opt
|
Number | 2000 | Number of graphics converted per time |
Returns:
Promise:(static) fetch(url, countPerTimeopt) [source]
Requesting a large volume geojson file.Solve the problem of main thread blocking
GeoJSON.fetch('https://abc.com/file.geojson',2000).then(geojson=>{
console.log(geojson);
})
Parameter | Type | Default | Description |
---|---|---|---|
url
|
String | GeoJSON file path | |
countPerTime
opt
|
Number | 2000 | Number of graphics converted per time |