开发者

How can I catch the Map movement in Google Maps?

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开发者_C百科 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 ?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜