Create dynamic GeoJSON files for polygons from MySql data?

Viewed 9

Previously I created a polygon layer in the Google Maps API using GeoJSON manually, adding a lot of polygon geometry for the boundary. I think there is a way like converting mysql data into GeoJSON files when new data is added but I don't know.

For example I created 2 polygons with GeoJSON and as seen in the GeoJSON code there are 2 geometry polygons, if I want to create more than 2 polygons then I have to add another polygon in GeoJSON.

 {
        "type": "FeatureCollection",
        "features": [
          {
            "type": "Feature",
            "properties": {
              "area": "1",
              "species": "Bird",
              "amount": "200"
            },
            "geometry": {
              "type": "Polygon",
              "coordinates": [
                [
                  [
                    109.26014900207518,
                    -7.63962487847275
                  ],
                  [
                    109.25851821899414,
                    -7.647621274679257
                  ],
                  [
                    109.28229331970215,
                    -7.654001270566328
                  ],
                  [
                    109.28332328796387,
                    -7.645409520500836
                  ],
                  [
                    109.26014900207518,
                    -7.63962487847275
                  ]
                ]
              ]
            }
          }
        ]
      }

I have MySQL data like this, how to automatically convert MySQL data into GeoJSON Polygon file?

INSERT INTO data_area (area, species, amount, coordinates) VALUES ('1','Bird','200',' 109.26014900207518,-7.63962487847275 109.25851821899414,-7.647621274679257109.28229331970215,-7.654001270566328 109.28332328796387,-7.645409520500836 109.26014900207518,-7.63962487847275'),('1','Snake','20',' 109.26014900207518,-7.63962487847275 109.25851821899414,-7.647621274679257109.28229331970215,-7.654001270566328 109.28332328796387,-7.645409520500836 109.26014900207518,-7.63962487847275'), 
('2','Snake','20','109.2640972137451,-7.6280553594618015 109.26624298095703,-7.637838429070729 109.28409576416016,-7.637328013583834 109.28546905517577,-7.63290438716138 109.28109169006348,-7.626268861716074 109.2640972137451,-7.6280553594618015')
0 Answers
Related