QUESTION: Is there a way that I could locate what the coordinates are of corner points of the google map each time I zooms in
, zooms out
, or shift
the map?
ELABORATING ON WHAT I MEAN:
In my google maps api code, I giving the map a specific width and height:
<style>
#map {
width:400px;
height:300px;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map"></div>
<script>
var mapOptions = {
center: new google.maps.LatLng(37.7831, -122.4039),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
</script>
Now when a user uses the scroll the look either further in the map or further out, this width and hight obviously stays the same, however the coordinates on the map located at the
top-left corner
top-right corner
bottom-left corner
bottom-right corner
change as the user shifts the map. I have been trying to find a way to obtain these coordinates but have failed in my attempts.
map.getBounds()
will return a bounds object containing the North, South, East and Western bounds of the map (as SouthWest, NorthEast).