mardi 17 février 2015

Gmaps4Rails build_markers not working in javascript


I'm trying to build a markers Json with build_markers. It seems to build the hash right when I display it in the page but somehow in javascript it returns null.


javascript (not using require tree if that matters)



function initialize() {

handler = Gmaps.build('Google');
handler.buildMap({ provider: {maxZoom:17, minZoom:5}, internal: {id: 'map'}}, function(){
markers = handler.addMarkers(<%= raw @hash.to_json %>);
handler.bounds.extendWith(markers);

handler.fitMapToBounds();
});

}

google.maps.event.addDomListener(window, "load", initialize);


controller



def index
@apartments = Apartment.all
@hash = Gmaps4rails.build_markers(@apartments) do |apartment, marker|
marker.lat apartment.latitude
marker.lng apartment.longitude
end
end


When checking source it just shows handler.addMarkers(null)





Aucun commentaire:

Enregistrer un commentaire