I am having response time issues using the following code to draw
circles on a map.
The more circles I add, the longer it takes for the map to draw. Any
ideas how I can address this issue or is this a known limitation.
function doDrawCircle(radius, latitude, longitude) {
var circlePoints = Array();
with (Math) {
if (circleUnits == 'KM') {
var d = circleRadius / 6378.8; // radians
}
else { //miles
var d = circleRadius / 3963.189; // radians
}
/*
var lat1 = (PI / 180) * center.lat(); // radians
var lng1 = (PI / 180) * center.lng(); // radians
*/
var lat1 = (PI / 180) * latitude; // radians
var lng1 = (PI / 180) * longitude; // radians
for (var a = 0; a < 361; a++) {
var tc = (PI / 180) * a;
var y = asin(sin(lat1) * cos(d) + cos(lat1) * sin(d) *
cos(tc));
var dlng = atan2(sin(tc) * sin(d) * cos(lat1), cos(d)
- sin(lat1) * sin(y));
var x = ((lng1 - dlng + PI) % (2 * PI)) - PI; // MOD
function
var point = new GLatLng(parseFloat(y * (180 / PI)),
parseFloat(x * (180 / PI)));
circlePoints.push(point);
bounds.extend(point);
}
if (d < 1.5678565720686044) {
circle = new GPolygon(circlePoints, '#000000', 2, 1,
'#000000', 0.25);
}
else {
circle = new GPolygon(circlePoints, '#000000', 2, 1);
}
map.addOverlay(circle);
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---