YamahaSY
YamahaSY

Reputation: 279

Google map radius

I need to find google map radius (visible area) in km. Can You give me some example? i tried `

var bounds = new google.maps.LatLngBounds();
var sw = bounds.getSouthWest(); 
var ne = bounds.getNorthEast();

var proximitymeter = google.maps.geometry.spherical.computeDistanceBetween (sw, ne);

`

but it returns same value every time

Upvotes: 0

Views: 1415

Answers (1)

Jordonias
Jordonias

Reputation: 5848

You're finding the cross-sectional distance. This will determine the vertical and horizontal distance of the shown map.

var bounds = new google.maps.LatLngBounds();
var sw = bounds.getSouthWest();
var ne = bounds.getNorthEast();
var east = new google.maps.LatLng(0, ne.lng());
var west = new google.maps.LatLng(0, sw.lng());
var north = new google.maps.LatLng(ne.lat(), 0);
var south = new google.maps.LatLng(sw.lat(), 0);
var width = google.maps.geometry.spherical.computeDistanceBetween(east, west);
var height = google.maps.geometry.spherical.computeDistanceBetween(north, south);

From this you can find the "radius".

Upvotes: 1

Related Questions