Determine southwest and northeast point for bounds in Google maps
I have a set of markers on google map (say 6). Now i want to zoom in only to certain level that displays all markers well for that i used getBoundsZoomLevel().
Problem is I dont know how to determine the BOUNDS from array of latitude and longitude.
Can someb开发者_运维知识库ody tell me how to determine south-west and north-east point for a bound???
I found this one post but i m not able to understand it as i dont know what is DIST... SouthWest and NorthEast Points
Take a look at LatLngBounds http://code.google.com/apis/maps/documentation/javascript/reference.html#LatLngBounds
As you added new LatLngs you can call extend(point:LatLng)
, the bounds will then contain all of your added LatLngs.
This is in Objective C, Hope the logic helps you:
-(NSArray *)calculateLongLatDegreesInMeters:(CLLocationDegrees)latitude {
float lat = M_PI * latitude / 180;
// Constants for calculating lengths
float m1 = 111132.92;
float m2 = -559.82;
float m3 = 1.175;
float m4 = -0.0023;
float p1 = 111412.84;
float p2 = -93.5;
float p3 = 0.118;
float eq1 = m1 + (m2 * cos(2 * lat)) + (m3 * cos(4 * lat));
float latitudeDegreeInMeters = eq1 + (m4 * cos(6 * lat));
float longitudeDegreeInMeters = (p1 * cos(lat)) + (p2 * cos(3 * lat)) + (p3 * cos(5 * lat));
NSString *latDegInMtr = [NSString stringWithFormat:@"%f",latitudeDegreeInMeters];
NSString *lonDegInMtr = [NSString stringWithFormat:@"%f",longitudeDegreeInMeters];
NSArray *arr = [NSArray arrayWithObjects:latDegInMtr,lonDegInMtr, nil];
return arr; //(latitudeDegreeInMeters, longitudeDegreeInMeters)
}
精彩评论