Creating, storing, and updating a json file in bubble

My application is storing Geojson strings in text fields within one of my databases, and those Geojson strings represent individual points on the map. What I am hoping to figure out is how to append newly created Geojson strings to a json file containing other merged Geojson strings, such that my Google Map javascript can reference the json file (hopefully stored on bubble).

Any idea how to do this? I am trying to leverage Bubble’s database and avoid using another service as a database (backendless.com).

Some examples linked to from here …

Hopefully that will help you ask more questions!

1 Like

Thank you, mishav. I believe I understand how I can combine json objects within Bubble, but the step that eludes me is how to save the array of objects to a json file.

It is entirely possible that my approach is flawed, so before you answer my question above, consider my goal. I would like to embed a Google map in my application using javascript. The example provided by Google requires that I reference a json file. (https://developers.google.com/maps/documentation/javascript/datalayer)

Does Bubble offer up my database somehow as a json file and I am not aware? If my database in Bubble was available as a local json file, then I could easily reference it within the embed.

So, if you could do me a flavor and have a look at the Google example and give me your two cents, I would appreciate it greatly. For now, I remain cornfused.

@destryhunt.dh I think you’re getting stuck with loadGeoJson. Your app would work better with addGeoJson where you can add JSON directly rather than from a file.

sample:

map.data.addGeoJson({
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 0,
      "geometry": {
        "type": "Point",
        "coordinates": [
          -122.084917,
          37.423156
        ]
      }
    },
    {
      "type": "Feature",
      "id": 1,
      "geometry": {
        "type": "Point",
        "coordinates": [
          -83.74379,
          42.280119
        ]
      }
    }
  ]
});
zoom(map);

reference:
https://developers.google.com/maps/documentation/javascript/reference/data#Data.addGeoJson

Wow, that is brilliant. Let me see if I can figure out how to apply what you just taught me…

I store a separate Geojson in my database within Bubble for every geographic point. Each geographic point within my database a field within a row, visually, and each row includes many different fields pertaining to that geographic point.

So, if I want to render my map for all geographic points, how would I get around not having to reference each of the hundreds of geographic points within the script?

1 Like

Probably the easiest way is to send the script a list of each attribute separately, and build them into the single list. For example:

mylist’s lat … [ -122.084917, -83.74379, ... ]
mylist’s lng … [ 37.423156, 42.280119, ... ]

3 Likes

@destryhunt.dh how did this go for you? I’m trying to get a custom Google Maps map into Bubble, but getting stuck on generating the geojson.