Simple Problem

Hi there,

I am building an application that stores the delivery boundaries of businesses. I have a separate table called boundaries that has fields for the latitude and longitude. Each business can have many of these boundary points and I use google maps with markers to capture the information.

No my problem is this - when a user wishes to edit a business I need to display the delivery area in a google maps using a javascript function. How can I pass the list of boundaries associated with the business to a javascript function?

Thanks, steve

I am building an application that stores the delivery boundaries of businesses. I have a separate table called boundaries that has fields for the latitude and longitude. Each business can have many of these boundary points and I use google maps with markers to capture the information.

No my problem is this - when a user wishes to edit a business I need to display the delivery area in a google maps using a javascript function. How can I pass the list of boundaries associated with the business to a javascript function?

You'll have a script tag in your view. Here's some rough pseudocode:

<script type="text/javascript"> var old_boundaries = <%= @business.boundaries.map { |b|                            [ b.latitude, b.longitude ]                          }.to_json %>; </script>

Your JS code can now refer to old_boundaries for the set of points.

Thanks, steve

--Greg