Skip to content

Instantly share code, notes, and snippets.

@xx7y7xx
Last active Apr 30, 2021
Embed
What would you like to do?
Convert OSM Bbox to GeoJSON
// OSM context
// const boundingBox = window.context.map().extent().bbox();
// const west = boundingBox.minX;
// const east = boundingBox.maxX;
// const north = boundingBox.maxY;
// const south = boundingBox.minY;
east=103.95809871524841
north=1.3401293903131355
south=1.3292472996510163
west=103.92966431487436
const convert = () => {
const feature = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[[west,south],
[east,south],
[east,north],
[west,north],
[west,south]]
]
}
}
featureCollection = {
"type": "FeatureCollection",
"features": [feature]
}
return featureCollection
}
console.log(JSON.stringify(convert().features[0]))
copy(convert().features[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment