トップ » 記事 » Google Maps に半径円を描く計算式

Google Maps に半径円を描く計算式

公開: 2023年09月17日, 更新: 2023年09月17日 by ちずぞう

グーグルマップ API は new google.maps.Circle で容易に半径 n km の円を描くことができるが

また使うかもしれない、そのロジック

var R = 6371;
var dLat = (point2.lat() - point1.lat()) * Math.PI / 180;
var dLon = (point2.lng() - point1.lng()) * Math.PI / 180;
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
  Math.cos(point1.lat() * Math.PI / 180) * Math.cos(point2.lat() * Math.PI / 180) *
  Math.sin(dLon / 2) * Math.sin(dLon / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
var d = R * c;

Leaflet を用いるケースは4年前に「地図に半径円を描く」で示した。

地図の利用度や親しみ度合いは、国によって大きな差があるように思う。日本は、世界で最も地図を読める国のひとつだろうと私は感じている。

最新記事=猿島の洪積台地 (2023年09月30日)
Japonyol