0

I'm using Google maps V3, I searching for a listener to catch the movement (navigation) of the map, can I do that?

If yes, how can I do that and how can I know the size of movement in x and y ?

EDIT : As I have a marker on the map, when I click on the marker a div is appeared in same position of the marker, but when I move the map, the maker moves in the same fashion, but the DIV is still in a fixed position, How can I move the div in the same way ?

Kai
  • 38,985
  • 14
  • 88
  • 103
Adham
  • 63,550
  • 98
  • 229
  • 344

1 Answers1

1

The maps event 'bounds_changed' will help:

google.maps.event.addListener(map, 'bounds_changed', function () {
  // whatsoever..., i.e.
  boundsObject = map.getBounds();
});

It returns a bounds object consisting of two LatLng objects (NE and SW )whose values can be retrieved like:

neLatLngObject = boundsObject.getNorthEast();
swLatLngObject = boundsObject.getSouthWest();
// or the center of bounds:
ctrLatLngObject = boundsObject.getCenter();

To find the distance between two points look here: Calculate distance between two points in google maps V3

Community
  • 1
  • 1
mckoch
  • 330
  • 1
  • 4