Hello,
This code in Python…
import re,sys
import geojson
from geojson import LineString, Point, Feature, FeatureCollection, dump
props = {"name": "Some name", "description": "Some description", "_storage_options": {"color": "MediumVioletRed"}}
linestring = LineString([(2.390588521957398, 48.85313149149458), (2.3488533496856694, 48.87182151098106)])
features = []
features.append(Feature(properties=props,geometry=linestring))
feature_collection = FeatureCollection(features)
with open('myfile.geojson', 'w') as f:
dump(feature_collection, f, indent=2)
… outputs this:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
2.390588521957398,
48.85313149149458
],
[
2.3488533496856694,
48.87182151098106
]
]
},
"properties": {
"name": "Some name",
"description": "Some description",
"_storage_options": {
"color": "MediumVioletRed"
}
}
}
]
}
However, to import a full map into Umap, it needs a bit more before and after:
{
"type": "umap",
"properties": {
"easing": true,
"tilelayer": {
"name": "OSM Sunny (jawgmaps)"
},
"licence": ""
},
"geometry": {
"type": "Point",
"coordinates": [
2.2780323028564458,
48.802962875092014
]
},
"layers": [
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "blah",
"description": "blah"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
2.3110949921647266,
48.81514649393979
],
[
2.2819232977235515,
48.84809311844251
]
]
}
}
],
"_storage": {
"displayOnLoad": true,
"browsable": true
}
}
]
}
, ie. “type=umap”, “layers”, and “_storage”.
Does someone know how to add those using geojson, and come up with a full file ready to build a new map from scratch?
Thank you.