#map{style: "height: 500px;" } - content_for(:script_body) do :javascript // create a map in the "map" div, set the view to a given place and zoom var map = L.map('map', { scrollWheelZoom: false }).setView([#{h(@conference.venue.latitude)}, #{h(@conference.venue.longitude)}], 11); // add an OpenStreetMap tile layer L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox', maxZoom: 18 }).addTo(map); // add a marker in the given location, attach some popup content to it and open the popup L.marker([#{h @conference.venue.latitude}, #{h @conference.venue.longitude}]).addTo(map) .bindPopup("#{escape_javascript(render '/conferences/venue_map_marker', venue: @conference.venue)}") .openPopup(); // Turn scrollwheel on when user clicks map.on('focus', function(e) { map.scrollWheelZoom.enable(); }); // Turn scrollwheel off once the map isn't in the viewport anymore $('#map').waypoint({ handler: function(direction) { map.scrollWheelZoom.disable(); //alert('map'); }, offset: '90%' }); $('#map').waypoint({ handler: function(direction) { map.scrollWheelZoom.disable(); //alert('map'); }, offset: '10%' });