2007年10月6日 星期六

gwebmap


add index.rhtml under app/views/gwebmap/



add traffic.css under app/public/stylesheets/

body {
background-color: #888;
font-family: Arial;
font-size: 20px;
margin: 25px;
}
#main {
margin: 0;
margin-bottom: 10px;
background-color: #eee;
border: 5px solid #333;
padding: 25px;
}

#form {
boarder: none;
text-align: center;
padding-bottom: 25px;
}

#map_div {
margin: 0px auto;
width: 800px;
height: 400px;
}

#notice {
color: red;
padding-top: 25px;
text-align: center;
}

ym4r

If you gem install ym4r

but ym4r.rb and ym4r directory are installed in your ruby installed directory
C:\ruby\lib\ruby\gems\1.8\gems\ym4r-0.6.0\lib

Try to copy ym4r.rb and ym4r directory to your rails directory
where you install ym4r_gm plugin

C:\Documents and Settings\ming\RailsApplication4\vendor\plugins\ym4r_gm\lib

The error message when you run gwebmap_controller.rbg will be solved.

class GwebmapController < ApplicationController
require "ym4r/yahoo_maps/building_block/traffic"
include Ym4r::YahooMaps::BuildingBlock
def index
@map = GMap.new("map_div")
@map.control_init(:large_map => true, :map_type => true)
@map.center_zoom_init([38.134557, -95.537109],4)
@map.icon_global_init(GIcon.new(:image =>
"/images/icon_incident.png", :icon_size => GSize.new(15,15), :icon_anchor =>
GPoint.new (7,7), :info_windows_anchor => GPoint.new(9,2)), "incon_incident")
@map.icon_global_init(GIcon.new(:image =>
"/images/icon_construction.png", :icon_size => GSize.new(15,15), :icon_anchor =>
GPoint.new (7,7), :info_windows_anchor => GPoint.new(9,2)), "icon_construction")
end
end


The problem is rails can't find the plugin during require command.
The error message as bellow

MissingSourceFile in GwebmapController#index

no such file to load -- ym4r/yahoo_maps/building_block/traffic

RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace


ming