LoginSignup
1
1

More than 5 years have passed since last update.

OpenLayers 3で表示中の地図の端の緯度経度を取得する

Posted at
// 表示している地図の端の座標を取得する

var extent = map.getView().calculateExtent(map.getSize());
var bottomLeft = ol.proj.transform(ol.extent.getBottomLeft(extent),
    'EPSG:3857', 'EPSG:4326');
var topRight = ol.proj.transform(ol.extent.getTopRight(extent),
    'EPSG:3857', 'EPSG:4326');
var endof_left   = wrapLon(bottomLeft[0]);
var endof_bottom = bottomLeft[1];
var endof_right  = wrapLon(topRight[0]);
var endof_top    = topRight[1];

console.log(endof_left);
console.log(endof_bottom);

console.log(endof_right);
console.log(endof_top);

function wrapLon(value) {
    var worlds = Math.floor((value + 180) / 360);
    return value - (worlds * 360);
}

(参考)
http://openlayers.org/en/latest/examples/moveend.html

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1