Browse ( File Picker ) button to import or pick csv & text coordinate file from mobile and draw them on (Bing Maps) map

If I have point coordinates

CSV file ot text file

P1,30.79036,31.40862
P2,30.79042,31.40904
P3,30.79009,31.40933
P4,30.78972,31.4094

I want to import file to my app and and use each point data to draw it on bingmap

for each point How can I extract point data

1- I want to make Global Variable list from lat,long coordinate
2- and make global variable for point name
Coordinate List

This is my attempt and I don't know if it is correct or not

What I'm missing is how to separate the coordinate and point name for each point separately and put them inside a list



Use these blocks in your empty sockets:

image

The button does not browse folders and gives me an error 2101

from where? the assets? somewhere else?

this
unknown
should be a filename, but as you can see from the error message it is a directory name...

do you want to read a file form the assets?
just set filescope to Assets and use the filename without path

Taifun

to convert a csv table into a list of lists use the list from csv table block and assign it directly to your list variable

unknown2

Taifun

Here is a tutorial showing how to do something similar with the MIT Map using a csv:

You probably could do something similar with your Bing Map. :thinking: to plot the csv coordinates.

the same error message



A heads up. that might make a difference in how you code your app.

Be aware, the Bing Maps api is being retired .

Bing Maps SDK for Android and iOS is deprecated and will be retired. Free (Basic) account customers can continue to use Bing Maps SDK for Android and iOS until June 30th, 2025. Enterprise account customers can continue to use Bing Maps SDK for Android and iOS until June 30th, 2028. To avoid service disruptions, all implementations using Bing Maps SDK for Android and iOS will need to be updated to use Azure Maps Web SDK by the retirement date that applies to your Bing Maps for Enterprise account type.

This may cause Bing Map users an issue next year

1 Like

what is your filename?
myCoordinates.csv?
put that as filename to read the file

EDIT: and to set the correct scope use the Scope property from the file component and set it to Asset

also do NOT use the add items to list block...
assign the list directly like this

set global from_csv_to_list to list from csv table get text

Taifun

1 Like

No I I want the user to be able to pick any csv or text file

from where? assets? shared storage?
try the filepicker component https://ai2.appinventor.mit.edu/reference/components/media.html#FilePicker

btw it is list from csv table...
unknown

Taifun

I CAN NOW PICK ANY TEXT FILE FROM PHONE
USE TEXT CONTENT TO DRAW POINTS ON MAP

blocks(70)
blocks(71)





Congratulations
Taifun

Some files were read without problems, while others gave me an error message


my PointCoordinates1.csv (238 Bytes)

From which directory did you try to pick the file?
When did it work and when not?
Which Android version are you using for your tests?

To read non media files which have been created by other apps you have to use SAF... to pick one of those files i.e. a text file of your choice from shared storage I think you also can use the filepicker component... I'm not 100% sure, because I did not test this...

Taifun

Android version?

android 13

this file working
ffPointCoordinates18.csv (446 Bytes)

location : / internal storage /DOCUMENTS/

but this file not working

my PointCoordinates1.csv (238 Bytes)

location : / internal storage /DOCUMENTS/

The different between them in the content

the second not working content

P1,30.78972106835117,31.40794463947712
P2,30.789692266392713,31.408396843153223
P3,30.78937784449846,31.40859507516323
P4,30.78890340939052,31.408433723527178
P5,30.78879940133065,31.40786165863572
P6,30.789361043320525,31.407554880979642

app read path and name only and cant read content

Try putting both files in the same directory, do they both work / not work ?

two file are in the same path : / internal storage /DOCUMENTS/

I note that

In the emulator the text in the first file copied and give me


the second file not copied

After exporting apk file and try the two file the same error message for two files

Screenshot 2024-06-30 152521

and nothing copied