2011-06-28 55 views

回答

0

Geokit是非常容易实现。如果您刚刚开始使用Google地图API,那么我会推荐从这里开始:https://github.com/jlecour/geokit-rails3

一旦你得到它的正确安装,你可以做这样的事情在你的控制器......

@event = Event.find(params[:id]) 
if @event.is_geocoded? 
    @map = GMap.new("map_div", 'map') 
    @map.control_init(:large_map => true, :map_type => false) 
    @map.center_zoom_init(@event.latlon,12) 
    @map.overlay_init(GMarker.new(@event.latlon, :title => @event.name, :info_window => @event.address_for_map_popup)) 
end 

在您看来,这样的事情:

- if @map 
    - initialize_map 
    = @map.to_html.html_safe 
    = @map.div(:width => 478, :height => 400).html_safe 

这是GMarker是创建地图标记并将其覆盖在地图顶部。

0

所以最好的方法可能是将它们的位置存储在数据库中(或先转换为坐标,然后再存储到数据库中)。从那里你可以使用像google maps javascript api这样的东西把引脚放到你生成的地图上。

http://code.google.com/apis/maps/documentation/javascript/

+0

所以你说我应该使用JavaScript API来让我的地图添加一个图钉到地图上与存储在数据库中的商店地址相关的区域。 – conpill

+0

是的。你可能会检查出上面提到的geokit ..我从来没有使用它,但它看起来像它实现了我在说什么。 javascript api很不错 – Msencenb