JavaScript
google
map

Google Map API 地図四隅の緯度経度取得

More than 5 years have passed since last update.

function initialize() {

var latlng = new google.maps.LatLng(35.689488, 139.691706);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);

//getBoundsは、地図の描画が終わってからでないと正確な値がとれないので、bounds_changedイベントに登録する。
google.maps.event.addListener(map, 'bounds_changed', function() {
var info = document.getElementById("info");
info.innerHTML = "左上 "+map.getBounds().getNorthEast().lat();
info.innerHTML += ", " + map.getBounds().getNorthEast().lng();
info.innerHTML += "<br>";
info.innerHTML += "右下 " + map.getBounds().getSouthWest().lat();
info.innerHTML += ", " + map.getBounds().getSouthWest().lng();
info.innerHTML += "<br>";
info.innerHTML += "中心 " + map.getBounds().getCenter().lat();
info.innerHTML += ", " + map.getBounds().getCenter().lng();
});

}

initialize();

sample