send9
send9

Reputation: 13

Rails 3 + Google Maps without a gem

I'm trying to integrate Rails 3 with Google Maps. I do not want to use a gem -- I just want to generate the array (hash?) used by the JavaScript API. I have this working manually, but not dynamically. I am using Haml, so the ERB examples are throwing me off.

Right now, my info comes out of Redis and is stuffed into a Ruby array in the JavaScript format Google Maps expects. I then try to access the array in my View. It almost-works, but there are no new lines -- it's one giant blob.

How do I fix it? Or what's a better way to do it?

Thanks in advance!

Upvotes: 1

Views: 857

Answers (2)

Sameer C
Sameer C

Reputation: 2797

Here's a simplified example:

https://gist.github.com/1017434

Upvotes: 2

eggie5
eggie5

Reputation: 1960

This isn't really rails question. The gamps api is javascript - you do it on the client in javascript.

It seems you have some data in redis, i'm assuming it's places you want to map. One way to get that data from redis on the server to javascript on the client is to deserialize it as a JSON string. Then serialize it on the client from the JSON string. Then you would just enumerate though the array of points and plot then using google provided maps api.

Upvotes: 0

Related Questions