0

I'm following this example here

Dynamically load Google Maps Markers with gmaps4rails

I'm trying to use a .js request instead of .json so I can render some other info within the same controller request. Using the .json method works great but once I switch to .js, it doesn't work. The data being sent is still run through the .to_gmaps4rails method to convert it into the JSON data.

When responding to the .json request, the console.log shows the response data interpreted as marker objects but it's just string data when responding to the .js request.

Any help would be much appreciated!

Community
  • 1
  • 1
Jeff Locke
  • 617
  • 1
  • 6
  • 17

1 Answers1

0

You should simply use:

JSON.parse(string)

Since result from .js isn't automatically converted to an object.

apneadiving
  • 114,565
  • 26
  • 219
  • 213
  • Yeah, that part is all set. Now I'm trying to figure out how to allow a user to move the map and to update the markers (on the map) and the partial that corresponds to those markers (aside from the sidebar function that gmaps4rails has) – Jeff Locke Jun 04 '12 at 07:39
  • Google maps api provides methods to get the boundaries of the current map. From these coordinates, you could load markers async. For the partial, I don't really understand your problem: once you've the markers, the rest should be fine – apneadiving Jun 04 '12 at 07:43