0

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();
    };
}
kaoscify
  • 1,743
  • 7
  • 37
  • 74
  • 2
    You mean bounds as the part of the map that is not covered by the panel? – davidkonrad Nov 04 '15 at 21:22
  • 1
    @davidkonrad Yes that's correct. That's what I am looking for. – kaoscify Nov 04 '15 at 21:28
  • related question: [How to offset the center point in Google maps api V3](http://stackoverflow.com/questions/10656743/how-to-offset-the-center-point-in-google-maps-api-v3) (not about getting the bounds, but about offsetting the center) – geocodezip Nov 04 '15 at 21:54
  • simliar question (but not answered): [Gmap LatLngBounds with an offset](http://stackoverflow.com/questions/26835119/gmap-latlngbounds-with-an-offset) – geocodezip Nov 04 '15 at 21:57
  • How about adjusting your code using this fiddle http://jsfiddle.net/upsidown/rat1fkkc/? – EugenSunic Nov 04 '15 at 22:35
  • @eugensunic That's interesting. Will have a look. But my panel appears after clicking the button. This map already has the panel positioned on the left. Thank you though. Checking the code. – kaoscify Nov 04 '15 at 23:15

0 Answers0