2013-11-21 53 views
1

我想調整線顏色,填充我的地圖圈內的顏色和不透明度。Gmaps4Rails V2調整圈屬性

<script type="text/javascript"> 
     circle = [{lng: <%= @listing.longitude %>, lat: <%= @listing.latitude %>, radius: 2500, strokeColor:"#0000FF",strokeOpacity: 1, strokeWeight: 3, fillColor: 'transparent'}] 
     handler = Gmaps.build('Google'); 
     handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){ 
     markers = handler.addMarkers(<%=raw @hash.to_json %>); 
     handler.bounds.extendWith(markers); 
     handler.addCircles(circle); 
     handler.fitMapToBounds() 
     handler.getMap().setZoom(12); 
    }); </script> 

更改半徑值可正常工作,但調整strokeColor,strokeOpacity,strokeWeight等對地圖沒有影響。

如何覆蓋這些設置?

回答

2

As the source says,你可以通過你的選擇作爲第二個參數:

circle = [{lng: <%= @listing.longitude %>, lat: <%= @listing.latitude %>, radius: 2500 }] 
circle_options = { strokeColor:"#0000FF",strokeOpacity: 1, strokeWeight: 3, fillColor: 'transparent' } 
handler.addCircles(circle, circle_options);