Create a polygon using FeaturesCollection

That would be using bloks not using features collection and geoJson.
By the way, I don´t find Call Map1.AddPolygon block.

I guess it was in other platform

Ok try this

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "Description": "Polígono Irregular en Camagüey",
        "FillColor": "#4488004e",
        "StrokeColor": "#000000",
        "StrokeWidth": 2
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [-77.90744304656984, 21.393422951386587],
            [-77.90880560874939, 21.395840413279284],
            [-77.91027545928956, 21.398257835208145],
            [-77.91045784950258, 21.401584222359443],
            [-77.90774345397949, 21.4008150644897],
            [-77.90516853332521, 21.400415500362858],
            [-77.90319442749023, 21.400375543890117],
            [-77.90160655975343, 21.40141440863241],
            [-77.89980411529542, 21.40089497718403],
            [-77.89834499359131, 21.39981615212504],
            [-77.89873123168947, 21.397818306921025],
            [-77.90744304656984, 21.393422951386587]
          ]
        ]
      }
    }
  ]
}

No way... still the same error: An internal error has occurred. Report a bug?

Only title and coordinates are acceptable for geojson in app inventor. All other properties returns error.

Thanks


Mmmmm....
Changing properties after creating polygons...

Are you working on Android or iOS ?

For iOS

FeaturesFromGeoJSON are not yet functional

I´m using Android.

But not clear yet on how to use it. I can not achieve the results I want, that is to load all polygon´s properties from FeartureCollection.

Could you, please :pray:, provide a functional example of a GeoJson with Title, Coordinates and all possible Properties? I have done many attempts but always failed.

I don´t know what happen. I paste this geojson on FeaturesFromGeoJSON
and works once, showing solid green polygons. I deleted the featureCollection and created again. When paste the same geojson, it creates solid red polygons in companion, not functional at all. No posible to change properties.


This is the result
Is like a red layer over all polygons.
I dragged a polygon in designer and was shown as it should in companion.

Now I loaded a polygons.json file and it´s functional again...
Can someone help me to understand?

First problem, this:

"FillColor": "#4488004e"

what is this meant to be?

I tryed fillcolor and fill for the inner color of polygon
None of those works
#4488004e was the value of one of many atempts

For me, some of the properties just do not seem to be working.

You may have to "translate" (back) some of the properties names, see here:

https://ai2.appinventor.mit.edu/reference/components/maps.html#FeatureCollection

@SteveJG may have a better idea of what is happening.

The json posted is for a single polygon. It renders green with no problem. I can change it's color easily. His image with the red polygons contains 32 or more polygons. @Aramis_Garcia did not provide the entire json file so I only have the single json to work with.

I suspect his issue when the entire set of Features is loaded and he may not have a robust internet.

When i worked a project that has 258 polygons, it wouldn't load on the main server but did on the code server and took a long time . There may be a similar issue on Aramis' data. Does he load a large file or a bunch of small files to features one at a time. :frowning_face:

Aramis', you might post all the json.

Steve

rGeoJson.json (164.2 KB)
This is my full geojson.
I put it iin app inventor as a file and works fine, and put it in app inventor as plain text in FeaturesFromGeoJSON and got the issue I posted before.
But... BUT... It could be I do not have a robust internet. The first time I loaded data as plain text it was successful, but not the second time I did it. I remember first time it took a long time before companion shows app interface.
By the other hand... why the red layer? When I dragged a polygon out off red layer, polygon came to light and works as it is supposed to be.

Result: The same red solid polygons, not useful.

If working with the FeaturesCollection component is just not happening, you could always workaround this by parsing the geojson file and generating runtime polygons, with all your properties, using blocks:

Here is an example - with a couple of random polygons added.
geojson.aia (6.8 KB)

image

(I included a hexToColour procedure which you will need if setting the FIllColor,StrokeColour etc.)

Blocks

1 Like

I can get this

I'll experiment some more.

1 Like

@SteveJG

Yes, I got the same result, but only when loading the json file, not using plain text in FeaturesFromGeoJSON nor loading from url.

@TIMAI2
That is amazing!!!
Thanks!! Thanks!!
Those blocks recharged my optimism again :slightly_smiling_face:

@SteveJG
It would be very good if FeaturesCollection works as it is suposed to work.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.