Created
January 2, 2012 12:10
-
-
Save lou/1550454 to your computer and use it in GitHub Desktop.
Google map Fullscreen with jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
var map = new google.maps.Map(document.getElementById("map_canvas"), {}); | |
var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687); | |
var googleMapWidth = $("#map_canvas").css('width'); | |
var googleMapHeight = $("#map_canvas").css('height'); | |
map.setCenter(newyork); | |
$('#enter-full-screen').click(function(){ | |
$("#map_canvas").css("position", 'fixed'). | |
css('top', 0). | |
css('left', 0). | |
css("width", '100%'). | |
css("height", '100%'); | |
google.maps.event.trigger(map, 'resize'); | |
map.setCenter(newyork); | |
return false; | |
}); | |
$('#exit-full-screen').click(function(){ | |
$("#map_canvas").css("position", 'relative'). | |
css('top', 0). | |
css("width", googleMapWidth). | |
css("height", googleMapHeight); | |
google.maps.event.trigger(map, 'resize'); | |
map.setCenter(newyork); | |
return false; | |
}); | |
}); |
how can add a button on a map
please help me someone
mhdayyoob,
map.controls[google.maps.ControlPosition.TOP_CENTER].push(document.getElementById('yourElement'));
You can read more about this here.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used your code as starter. Thanks! I added a container around so that the button are still visible (particularly the exit button) even if the map is full screen.
JavaScript had to be adapted as well.