最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to find minimum & maximum values latitude and longitude on google map - Stack Overflow

programmeradmin2浏览0评论

I want to locate the minimum latitude/longitude & maximum latitude/longitude value of visible region region of Google map.For eg: if i drag the map along any axis than at drag end, java script will alert me with minimum/maximum latitude/longitude values.

I want to locate the minimum latitude/longitude & maximum latitude/longitude value of visible region region of Google map.For eg: if i drag the map along any axis than at drag end, java script will alert me with minimum/maximum latitude/longitude values.

Share Improve this question edited Sep 5, 2011 at 7:24 Tatu Ulmanen 125k34 gold badges189 silver badges185 bronze badges asked Sep 5, 2011 at 7:19 amit hasijaamit hasija 231 silver badge4 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

You can hook an event listener for Map -> idle event:

This event is fired when the map bees idle after panning or zooming.

Inside that event you can call the Map.getBounds() method. You can then use the LatLngBounds.getNorthEast() and LatLngBounds.getSouthWest() methods to get the top-left and bottom right corners of the visible region.

  • Demo here
  • google.maps.Map reference
  • google.maps.LatLngBounds reference

Use google.maps.Map#getBounds

For example:

var map = new google.maps.Map(document.getElementById('map-div'), { /* options */});
var bounds = map.getBounds();

http://code.google./apis/maps/documentation/javascript/reference.html#Map

发布评论

评论列表(0)

  1. 暂无评论