I’m learning, as a project I want to learn how to create and draw a polygon in canvas give a set of geojson coordinates? I have no idea what the steps are to make this happen.
Here is the geojson code I created using geojson.io
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"stroke": "#555555",
"stroke-width": 2,
"stroke-opacity": 1,
"fill": "#555555",
"fill-opacity": 0.5
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-1.910746693611145,
50.743831635778356
],
[
-1.9105897843837738,
50.74381169283351
],
[
-1.9105750322341917,
50.743852851667825
],
[
-1.9105388224124908,
50.743847335537495
],
[
-1.91052608191967,
50.743887645705726
],
[
-1.9107212126255035,
50.74391268042433
],
[
-1.910746693611145,
50.743831635778356
]
]
]
}
}
]
}
It is a simple shape
And I would like to take the coordinates and transform them to a unit measurement I can then take and draw it using canvas context, using moveTo()
, lineTo()
Any help will be much appreciated