Ruby Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesRuby Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 18th, 2010, 07:56 PM
Think Think is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 30 Think User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 15 m 2 sec
Reputation Power: 4
Need help loading Google Maps markers from my RoR model

Hey guys, this is my first time posting in this section of Dev Shed. I am working on a Databases project at school so I decided to learn RoR.

I am trying to work on the View for one of my database tables, here is the "index.html.erb" that was generated by my scaffold I created to store pizza places:

Code:

<h1>Listing Pizza Places</h1>

<table>
  <tr>
    <th>Name</th>
    <th>OwnerName</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @pizzaplaces.each do |pizzaplace| %>

  <tr>
    <td><%= pizzaplace.name %></td>
    <td><%= pizzaplacet.ownername %></td>
    <td><%= link_to 'Show', pizzaplace %></td>
    <td><%= link_to 'Edit', edit_pizzaplace_path(pizzaplace) %></td>
    <td><%= link_to 'Destroy', pizzaplace, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to 'New Pizza Place', new_pizzaplace_path %>


Okay so I have a map running in an adjacent <div>, what I want to do is load markers onto the map using Google Maps API V3. I hope to do this by including some sort of javascript function call inside the "each do" loop of the code (im not sure what type of code this is.. "erb" is it called a partial??? Ruby??? Rails???)

This is what I have tried... with no effect.. I have bolded the changes.


Code:
 <script type="text/javascript">

  function addMarker(Latitude, Longitude) {
    if( typeof addMarker.counter == 'undefined' ) {
          addMarker.counter = 0;
      }
    addMarker.counter++;
    
    myMarkers[addMarker.counter] = new google.maps.Marker({
          position: new google.maps.LatLng(Latitude, Longitude),
          map: map, 
          title:"test"});
   }

  </script>

<h1>Listing Pizza Places</h1>

<table>
  <tr>
    <th>Name</th>
    <th>OwnerName</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @pizzaplaces.each do |pizzaplace| %>
<script type="text/javascript">
        addMarker(<% pizzaplace.latitude %>, <% pizzaplace.longitude %>);   
    </script>
  <tr>
    <td><%= pizzaplace.name %></td>
    <td><%= pizzaplacet.ownername %></td>
    <td><%= link_to 'Show', pizzaplace %></td>
    <td><%= link_to 'Edit', edit_pizzaplace_path(pizzaplace) %></td>
    <td><%= link_to 'Destroy', pizzaplace, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to 'New Pizza Place', new_pizzaplace_path %>


I hope something like this is possible, I have only a basic understanding of RoR and the embedding of JS inside html.

Thanks to anyone that decides to help...

-Paul

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesRuby Programming > Need help loading Google Maps markers from my RoR model

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap