Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible, after "bounds_changed" event, to get polygon coordinates covering the difference between new bounds and previous bounds?

Any idea how to do it? Any help would be greatly appreciated.

share|improve this question

As I am sure you are aware the bounds_changed event occurs after the bounds have changed, therefore the previous bounds are "lost".

I would approach this by having two global variables called prevBounds and newBounds. Then, within my handler for the bounds_changed event I would do the following:

  1. Set prevBounds equal to newBounds which will give me my previous bounds
  2. Set newBounds equal to the map's current bounds which will give me the new bounds

After the bounds_changed event I would have two variables; one containing my previous bounds and one containing the new bounds of the map. Then you can calculate the difference between them.

share|improve this answer
Yes, I know that. I should be more clear in my question. What I wanted help with is this actual calculation between new and previous bounds. I suck at geographic calculations... Anyway, thank you for your answer. – Arek Aug 31 '12 at 11:32
@Arek I see what you mean now, so what do you actually want to calculate the difference of? Width, Height, Area? Of course if the bounds changed because of a pan then there will be no change in size, just location - what difference would you want to calculate in that case? – CHenderson Sep 1 '12 at 10:48
Maybe it will be best explained with an image. What I need is the coordinates of the green area. – Arek Sep 3 '12 at 6:28

getBounds() returns a LatLngBounds object that supports equals(), intersects(), contains(), etc.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.