gmaps4rails 2 + rails 4 + ruby 2.0
<script>
handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
markers = handler.addMarkers(<%= raw @geo_hash.to_json %>);
});
handler.map.centerOn({ lat: <%= raw @geo_city[0][:lat] %>, lng: <%=raw @geo_city[0][:lng] %> })
handler.getMap().setZoom(7)
</script>
@geo_hash = [{:lat =&gt; 16.9916, :LNG =&GT; 81.7838, :infowindow =&gt;“火车站”, :picture =&gt; {:url =&gt;“/ assets / web / blank_red.png ”,:width =&gt; 32,:height =&gt; 32}, :title =&gt;“abc temple”} ]
@geo_city = [{:lat =&gt; 15.8273, :LNG =&GT; 78.047, :infowindow =&gt;“巴士站”, :picture =&gt; {:picture =&gt;“/ assets / web / ** blank.png”,:width =&gt; 32,:height =&gt; 32}, :title =&gt;“A.S.Peta”}}
我想在Google地图上使用两个不同的标记,但只有一个标记即将出现?有什么建议吗?
答案 0 :(得分:0)
我得到了解决方案......
<script>
handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
markers1 = handler.addMarkers(<%= raw @geo_hash.to_json %>);
markers2 = handler.addMarkers(<%= raw @geo_city.to_json %>);
});
handler.map.centerOn({ lat: <%= raw @geo_city[0][:lat] %>, lng: <%=raw @geo_city[0][:lng] %> })
handler.getMap().setZoom(7)
</script>
感谢。