Search code examples
ruby-on-railsjsongmaps4rails

Gmaps4rails: How to add a custom marker to json in server?


Is it possible to add a custom marker to json after this:

@json = @myObjects.to_gmaps4rails

I'd like to add one more marker to that json, which would be other than myObject. Actually in my case it would be marker that would represent user location. I have all the needed information in my controller, but what is the easiest way to extend that json with one more marker?


Solution

  • Two solutions here:

    • some string manipulations

    • Parse the json => Array of hashes => add your data to the array => call to_json on the array