我已经使用Rails 4和Gmaps4Rails GEM构建了一个应用程序。我有一张带有标记的地图(效果很好)。我想添加一个搜索框和功能来搜索地图。因此,该地图将围绕搜索的期限(像城市一样),然后在附近显示任何市场。我找不到有关如何通过GMAPS4RAILS执行此操作的文档。关于如何完成此操作的任何想法?
如何使用一个PIN
更改地图(GMAPS4RAILS)的默认缩放您必须在地图上添加到页面的视图中,将线行添加到一系列"处理程序"行。下面的代码从Apneadiving的答案到一个不同的问题,该问题帮助我找到了答案。下面的第二部分设置了变焦级别(handler.getMap().setZoom(8);
)。
handler.buildMap( {internal: {id: 'map'}}, function(){
// handler.map is the proxy object created by the gem,
// where you can add your custom methods,
// like centerOn
handler.map.centerOn([-34.397, 150.644]);
// handler.getMap() is the google map object
// you can also access it with handler.map.getServiceObject()
handler.getMap().setZoom(8);
});