Apologies for the perhaps overly simplistic question. I have a Location data type that includes a Google Map Location as one of its fields. I also have a map that accesses a list of Locations. I want to include the current geographic location as an item on the map so I need to create a custom state of type Location (perhaps called “user-location”) to be able to add this to the list of Locations displayed on the map.
My question is - how do I create this custom state “user-location” using the current geographic location - without writing the item to the database?
NOTE: I was already able to create a list including items from the database and current geographic location by having the map use geographic address as its marker type instead of Location but this disables my ability to show the current geographic location marker as distinct. I am sure this functionality may well exist in some of the plugins and I will go there later but the ability to create a custom state based on one of its fields would be helpful to know in any case - if this is possible?
I hope that is clear (??)
Thanks for any help with this,
David
Hi there. I’m not certain that this is possible with custom states. Someone more knowledgeable (Maybe @jon2?) can correct me if I’m wrong. That said, I’ve been looking at Jon’s JSONMachine plugin recently for a similar problem. Might be worth a look.
AFAIK bubble doesn’t let you natively modify or otherwise merge/manipulate/etc data inside a db type locally on the page without writing to the database.
Frankly, this can be a serious hurdle when constructing highly scalable apps since any operation you might want to do with the data inside a custom data type requires calling on the db, which can be fairly ‘expensive’ in terms of sever capacity.
If you want to create your custom Location type locally on the page and then merge it with a list ofLocations from the db, AFAIK you are out of luck. That being said, I have yet to run into a scenario where you couldn’t use RegEx, JSON machine, or some other custom scripting to be able to merge built-in local types (like texts, geolocations, numbers, etc) with data retreived from the DB and achieve whatever is necessary.
What @cmarchan proposed ought to let you read in a list of db things (as JSON), add your other local thing to that JSON and then display the merged resulting JSON in your RG.
Another hack-around is to create a dummy Location thing and always include that dummy thing in your search results. You would then add a yes/no field such as this is a dummy to your Location type.
Then you could put a conditionally shown group in the repeating row based on the dummy thing’s yes/no value. Basically if this row’s Location is a dummy is yes show an alternate group or set the source value to read from the page state rather than from the current row’s Location
If many things happen when you select a row (like the map changes position, title text changes, etc) then you’ll need to individually set any states you’ll need in a workflow rather than simply using setting current row’s thing or setting a group’s data source to current row’s Location It adds complexity for sure.