After facing the
undefined method gmaps at the line
with the code line :
<%= gmaps("markers" => {"data" => @json, "options" => { "draggable" => true } } ) %>
That does not seem to work in Gmaps4rails 2.1.0
Detailed problem and answer for it in here.
What I am asking in here is , provided the answer in the previous link, for me to be able to make the marker draggable, how should I write this method ?
1 : handler.addMarker(<%= raw @hash.to_json %>,<% {draggable => :true }%>)
or
2 : handler.addMarker(<%= raw @hash.to_json %>,<% "draggable" => true }%>)
or
What?
It just seems to not work, and the map does not load, also I'd like to know where to put it in the code,
handler = Gmaps.build('Google');
// here ?
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
// or Here ?markers = handler.addMarkers(<%= raw @hash.to_json %>,<%"draggable" => true %>);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
Update #1 : Solved
I found the answer on github, it requires a bit of time reading through the doc, but hey , It's worth taking a look at , in the end, it is exactly the answer to this question.
Pass google options as a second argument:
handler.addMarkers([
{
lat: 0,lng: 0,
picture: {
url: "/logo.png",
width: 36,
height: 36
},
infowindow: "hello!"
},
]
{
draggable: true
}
);
doc here: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Js-Methods