In this example, you can see the oldBounds
(aka my initial bounds) when the map is loaded. But how can I get the actual newBounds
when the #panel
is overlaid on top of the map? Try clicking the Launch Panel button and see: http://jsfiddle.net/3npoupdL/
I guess one approach could be to resize the #map-canvas
once the #panel
is shown?
Looking for bounds that are not covered by the panel once it is opened.
Here's my JS code:
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(41.879535, -87.624333),
scrollwheel: false
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var oldBounds = document.getElementById("old-bounds");
var newBounds = document.getElementById("new-bounds");
google.maps.event.addListener(map, 'bounds_changed', function () {
oldBounds.innerHTML = "old bounds: " + map.getBounds();
});
var btn = document.getElementById("btn");
btn.onclick = function () {
$("#panel").addClass("show");
newBounds.innerHTML = "new bounds: " + map.getBounds();
};
}