I have a google map on the right part of the screen and house listings on the left similar like airbnb. When user moves the google map the listings are refreshed with AJAX request.
I would like to hide the google map on small screen devices. But when I hide google map, weirdly, it still returns bounds (should return 0 as there is no map) but map.getBounds().getSouthWest().lat()
and map.getBounds().getNorthEast().lat()
same, and map.getBounds().getSouthWest().lng()
and map.getBounds().getNorthEast().lng()
.
I do not get why lat and lng values are equals.
Here is my bounds call;
...
new google.maps.event.addListener(map, 'idle', function(){
params = get_bounds();
request_listings( extra_params );
console.log(params);
});
/*
*Utility function: To get the bounds of the map
*/
function get_bounds(){
return {
sw_lat : map.getBounds().getSouthWest().lat(),
sw_lng : map.getBounds().getSouthWest().lng(),
ne_lat : map.getBounds().getNorthEast().lat(),
ne_lng : map.getBounds().getNorthEast().lng()
};
...
it logs to console; map is not visible
Object {sw_lat: 40.983198400000006, sw_lng: 28.853608399999985, ne_lat: 40.983198400000006, ne_lng: 28.853608399999985}
And this is when map is visible;
Object {sw_lat: 40.802046203851475, sw_lng: 28.853608399999985, ne_lat: 40.983198400000006, ne_lng: 29.196244508398422}
To compare,
sw_lng the same for both case, and ne_lat the same with/without map. So I am getting these values but why not other or why I am getting value when map is not visible.
Thank you