Skip to content

Instantly share code, notes, and snippets.

@dannyvassallo
Created April 8, 2015 15:40
Show Gist options
  • Save dannyvassallo/27f5e3ae9901eb146636 to your computer and use it in GitHub Desktop.
Save dannyvassallo/27f5e3ae9901eb146636 to your computer and use it in GitHub Desktop.
Your CSS
<style>
#map_canvas {
height: 250px;
margin: 0;
padding: 0; }
</style>
Put this where you want the map to show
<div id="map_canvas"></div>
These are your javascripts.
This should go in your footer but what really matters is that it goes above
<script src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false"></script>
This one
<script>
function initialize() {
var mapOptions = {
zoom: 14,
zoomControl: false,
scaleControl: false,
scrollwheel: false,
disableDoubleClickZoom: true,
center: new google.maps.LatLng(40.057767,-74.111149),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
new google.maps.Marker({map:map,position:map.getCenter()})
google.maps.event.addListener(map, 'center_changed', function() {
//a value to determine whether the map has been resized
var size=[this.getDiv().offsetWidth,this.getDiv().offsetHeight].join('x');
//when the center has changed, but not the size of the map
if(!this.get('size') || size===this.get('size')){
this.setValues({size:size,_center:this.getCenter()});
}
//when the map has been resized
else{
google.maps.event.addListenerOnce(this,'idle',function(){
this.setValues({size:size,center:this.get('_center')});});
}
});
//trigger the resize-event to initialize the size and _center-values
google.maps.event.trigger(map,'center_changed',{});
}
google.maps.event.addDomListener(window, 'load', initialize);
$(function(){
function add(){
$(this).addClass('active');
}
function remove(){
$(this).removeClass('active');
}
function scrolly(button, div){
$(button).click(function() {
$('html, body').animate({
scrollTop: $(div).offset().top
}, 2000);
});
}
scrolly('#aboutbtn', '#about');
scrolly('#homebtn', '#home');
scrolly('#hours', '#location');
$('.navbar-nav li').mouseenter(add).mouseleave(remove);
});
//= _map
//= _nav
;
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment