Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

2 Answers 2

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

share|improve this answer

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

Your Answer

 
discard

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.