Skip to first unread message

Naturpark Lahn-Dill-Bergland

unread,
Mar 22, 2019, 7:14:44 AM3/22/19
to MIT App Inventor Forum
Hello,
I´m having problems with the markers in my app. It´s a very complicated app so this is just the extract of a very small part of it.
I create Markers for every row in a table. Every row contains longitude, latitude, a reference to the runtime marker and a description for the place.
While referring to the runtime marker works in the first part (changing description) and most of the time also in the second part (the when Button1.Click part), it says "Property setter was expecting a com.google.appinventor.components.runtime.Marker component but got a String instead." when I wait to long or open and close another screen (only sometimes) before I press the Button. Directly after creating the marker, it looks like this in the list: com.google.appinventor.components.runtime.Marker@bc03069 and it looks the same when it behaves like a string.
Does anybody know the problem and how to fix it? Creating the markers again and again is not likely to be the best solution, is it?
blocks(1).png

TimAI2

unread,
Mar 22, 2019, 7:29:38 AM3/22/19
to MIT App Inventor Forum
Looks like you are trying to call the whole row (all the items) as opposed to a single item on that row ?

Please give us an idea of the content/layout of "global Places"

ABG

unread,
Mar 22, 2019, 8:50:56 AM3/22/19
to MIT App Inventor Forum
You are trying to save Marker components in the 3rd column of table Places into TinyDB.

TinyDB can't hold runtime components.

Runtime components can't be passed to other Screens.
They die when you switch screens.

BTW, you should not open Screen1.
See the Screens section of FAQ

ABG



SteveJG

unread,
Mar 22, 2019, 8:56:06 AM3/22/19
to MIT App Inventor Forum
These two 'tutorials' show how to handle Map Markers using a csv file ...  National Parks    and  https://groups.google.com/forum/#!msg/mitappinventortest/9fSoh6eUmlc/Og3iQOmCAgAJ   and  https://groups.google.com/forum/#!searchin/mitappinventortest/National$20Park%7Csort:date/mitappinventortest/0aZ1r18hyfQ/cX0bB7xkBQAJ   using a csv file.   It works fine this way and you might find it better to control your destination markers.

Does this model help?

Regards,
Steve



Naturpark Lahn-Dill-Bergland

unread,
Mar 25, 2019, 6:34:44 AM3/25/19
to MIT App Inventor Forum
I don´t really save the markers in TinyDB but in a global variable with the same name. I know that TinyDB can´t hold markers but the variable seems to work quite good most of the time, so I replace the marker String I get from the DB every time when I open the screen.
I also know that runtime components can´t be passed, but I thought I can use them again on the old screen if I opened and closed another screen in between. Sometimes it seems to work but maybe I will now recreate the markers after the other screen closed. But then there will still be the problem with the markers "dying" when the screen is opened too long...
In my real program I don´t open Screen1; I have the markers on Screen1. I just made up an extra screen for the example.

Thanks for the fast answer and the tips :)

SteveJG

unread,
Mar 25, 2019, 8:38:30 AM3/25/19
to mitappinv...@googlegroups.com
Do you really need run time Markers?    Do you know you can 're use' design time Markers  (the ones with the default names like Marker1, Marker2, Marker3...).?  Change the latitude / longitude coordinates for the Marker as you need to display a different destination.  Place only one design time Marker or a dozen or so and show/hide them with the Marker1.Visible property set to true or false.

From your description, it appears you may be over engineering your Project.   We don't know because you did not share all your Blocks and describe completely how you are using the markers (an example of what your Places lists looks like).

It is simple to design a Project using a single screen.   Usually it is not necessary to use multiple screens and discover the complexity of passing variables from screen to screen (use virtual screens).  How do  you create your Places List?  I imagine it is a list of csv type data .        latitude,longitude,placeName    or something like that. Is that true?    How many locations are you working with?

You use   open another screenName ... Screen1.    A coding rule is  never open Screen1 .using that Block..simply close the screen you are using      close screen   instead.  Opening Screen1 multiple times creates multiple instances of Screen1 in memory.  You do not want to do that.

If you do not use a TinyDB in your real Project, why do you show a TinyDB in your example?    If you want specific help, you either need to show the real code Block image   and or an aia.....

Regards,
Steve

Naturpark Lahn-Dill-Bergland

unread,
Mar 25, 2019, 11:07:42 AM3/25/19
to MIT App Inventor Forum
Hi Steve,

yes, I really need runtime markers because users can create new "places". I have one design time marker which I use as a prewiew marker (so users can see where their "place" will be created).
I´m fiddling with my project for more than half a year now and am sure I´m not overengineering any longer; it´s just big (six screens for an app that lets users create, filter and delete finding places for edible plants on a map, plus an encyclopedia with plants and a copyright page).
And as I already wrote, I do not open Screen1 with that block in my app, it was just an extra screen (I´ve deleted it by now) with the example. That I must never open Screen1 using this block I´ve learned the hard way...
With TinyDB I think I wasn´t clearly enough: I use it for most of the values in my list of finding places (e.g. plant name, ID, latitude & longitude, description) but not for the runtime markers. They are referred to as entries in a list of list (global Places) while the app is running. Everytime this list is changed, the TinyDB gets changed, too (new entries, deleted entries). But I don´t save the runtime markers in the TinyDB because there´s no use for it. When the app is started again, I fetch the updated entries from TinyDB which contain latitude and longitude for each finding place and use it to create new markers.

But I´ve already solved the problem; creating the markers as well after opening and closing another screen did work for now; l´ll have to see if the problem still occurs somewhere later.

Thank you very much for your advice,
Eva
Reply all
Reply to author
Forward
0 new messages