Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

geojson on map

122 views
Skip to first unread message

Tamir

unread,
Jun 19, 2019, 5:12:08 PM6/19/19
to MIT App Inventor Forum
hi

How do i make the Map component to read geojson / kml file from url ?

thanks

SteveJG

unread,
Jun 19, 2019, 5:36:13 PM6/19/19
to mitappinv...@googlegroups.com
App Inventor is not kml file user friendly.  Geojson files work ok.  Where are you downloading your geojson files?    To learn to use geojson files to render on a map, I recommend experimenting by downloading small geojson files and placing the file in Media to see how a FeatureCollection works. Use the get FeatureCollection.FeaturesFromGeojson to  Block

make the Map component to read geojson from a url  ... use the call FeatureCollection.LoadFromURL  block Tamir  to create a FeatureCollection.  Display the FeatureCollection.    Large geojson files cannot be rendered.  My experience is files larger than about 200 kb in size may fail to load. Even small files take a while to load and render on a map.  


make the Map component to read kml from a url ... App Inventor 2 cannot read anf render a kml  (keyhole markup language) track directly to a Map component.  kml files are a special type of xml file.  You can use the Web component to possibly capture the kml file but you have to process  the file to display Map Features, Polygons or Lines.   

Regards,
Steve

Tamir

unread,
Jun 19, 2019, 6:51:17 PM6/19/19
to mitappinv...@googlegroups.com
thanks a lot steveJG

my geojson files are created from GTFS - General Transit Feed Specification. the size of the files is 30-50 kb.

1. when i downloaded the geojson file and placing the file in Media in the app it worked great!
2. when i try to read from url (google drive) , from the designer i've got 500 Internal Server Error The call failed on the server; see server log for details.       

any ideas?




SteveJG

unread,
Jun 19, 2019, 7:21:55 PM6/19/19
to MIT App Inventor Forum
OK.  Apparently you are doing the right things.   That the geojson loads and renders when stored on the device is great.

Here are some possibilities why you do not get the url to work:

1) When you download directly, you may get headers etc. that the component can not process when you download the file.  500 means 'something' went wrong on the Web site server.  The code unfortunately is non specific.   Does the same thing happen if you compile your app and do not access the url from Companion?

2)  You might prepare a small example and post the blocks and / or the aia so someone can look at this..  The issue might be how you use call FeatureCollection.LoadFromURL  

3) The Web site might restrict using the geojson as a direct access.  I am guessing.

4) What version of Android are you using?   Some versions of Android have issues with certain features of the Map component.  I know for certain Android 4.2.2 does.

5)  It might be interaction between Map  and the real time loading of the geojson.   Some kind of timing issue.

Without a copy/link of the info you use, this is impossible to debug.
Reply all
Reply to author
Forward
0 new messages