gpt4 book ai didi

ruby-on-rails - Gmaps4Rails : How to open the Infowindow of the single marker by default when the Google maps is loaded (without clicking on the marker)

转载 作者:行者123 更新时间:2023-12-02 00:27:46 27 4
gpt4 key购买 nike

我在我的 Rails 应用程序中使用 Gmaps4Rails 加载谷歌地图。一切正常。我有一个标记,我想在加载谷歌地图时默认打开信息窗口(不点击标记)。请帮助我如何使用 Gmaps4Rails gem 实现这一点?

我已经尝试了以下代码片段,但它不起作用。

<% content_for :scripts do %>
<script type="text/javascript" charset="utf-8">
Gmaps.map.callback = function() {
if (Gmaps.map.markers.length == 1) {

var marker = Gmaps.map.markers[0];
var infowindow = marker.infowindow;
infowindow.open(Gmaps.map.map, marker);
<%#*alert("Gmaps info open");%>
}
}
</script>
<% end %>

这是 apneadiving 在 How do I make an infowindow automatically display as open with Google-Maps-for-Rails 中提到的解决方案

感谢您的帮助和支持。

最佳答案

代替

infowindow.open(Gmaps.map.map, marker);

尝试

infowindow.open(Gmaps.map.map, marker.serviceObject);

我也无法打开信息窗口,这似乎对我有用。

关于ruby-on-rails - Gmaps4Rails : How to open the Infowindow of the single marker by default when the Google maps is loaded (without clicking on the marker),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8213093/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com