473,488 Members | 2,516 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Restaurants Google

2 New Member
Hi. I've been trying to play with this for a while now but I haven't seemed to get it to work. I have a admin controller, which is scaffolded, to input the lat and long along with info. I have a restaurant controller that will display the map with the points. I can get the map to show but the points do not show.


Code: ( text )
class CreateRestaurants < ActiveRecord::Migration
def self.up
create_table :restaurants do |t|
t.column :category, :string
t.column :name, :string
t.column :address, :string
t.column :phone, :string
t.column :hours, :text
t.column :more_info, :text
t.column :latitude, :float
t.column :longitude, :float
end
end

def self.down
drop_table :restaurants
end
end

class RestaurantController < ApplicationController

def map
@restaurants = Restaurant.find :all
end
end

--index.rhtml--
<div id="map" style="width: 500px; height: 300px"></div>

--restaurant.rhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Restaurants: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
<%= javascript_include_tag 'map' %>
<script src="http://maps.google.com/maps?file=api&v=2&key=KEY"
type="text/javascript"></script>
<script type="text/javascript">var restaurants=<%= @restaurants.to_json %>;</script>
</head>

<body>
<p style="color: green"><%= flash[:notice] %></p>

<%= yield %>

</body>
</html>

--map.js--
var map;
var centerLatitude = 42.733868932421856;
var centerLongitude = -84.47994947433472;
var startZoom = 16;
var markerHash = {};
var currentFocus = false;

function addMarker(latitude, longitude, id) {
var marker = new GMarker(new GLatLng(latitude, longitude));

GEvent.addListener(marker, 'click',
function() {
//marker.openInfoWindowHtml(description);
focusPoint(id);
});
map.addOverlay(marker);
return marker;
}

function init() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);

for (var i=0; i<markers.length; i++) {
//addMarker(restaurants[i].latitude, restaurants[i].longitude, restaurants[i].name);
var current = markers[i];
marker = addMarker(current.latitude, current.longitude, current.id);
markerHash[current.id]={marker:marker, address:current.address, visible:true};
}
}
}

window.onload = init;
window.onunload = GUnload;
Jul 19 '07 #1
0 2217

Sign in to post your reply or Sign up for a free account.

Similar topics

13
2914
by: fuzzyman | last post by:
I've hacked together a 'GoogleCacheServer'. It is based on SimpleHTTPServer. Run the following script (hopefully google groups won't mangle the indentation) and set your browser proxy settings to...
3
4183
by: Alastair | last post by:
Hello guys, I've been building a search facility for an intranet site I'm part of developing and we've been building a search engine using Index Server. It mostly works, however there have been...
25
2512
by: Tor Erik Sønvisen | last post by:
Hi I need to browse the socket-module source-code. I believe it's contained in the file socketmodule.c, but I can't locate this file... Where should I look? regards tores
9
2385
by: Ray5531 | last post by:
Sorry if this is irrelevant to this website,but I didn't find a better place to ask this question.I sent an email to google as well which I didn't recieve the answer.I'm creating a website and...
2
2013
by: gen_tricomi | last post by:
THE IMPORTANCE OF MAKING THE GOOGLE INDEX DOWNLOADABLE I write here to make a request on behalf of all the programmers on earth who have been or are intending to use the Google web search API...
1
7269
by: xahlee | last post by:
Elisp Tutorial: Make Google Earth Xah Lee, 2006-12 This page shows a example of writing a emacs lisp function that creates a Google Earth file, and creates a link to the file, as well a link...
16
2551
by: Duncan Booth | last post by:
Google have announced a new service called 'Google App Engine' which may be of interest to some of the people here (although if you want to sign up you'll have to join the queue behind me): From...
0
7108
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7352
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.