Check if overlay exists so i can not be added twice or more
Hello,
I'm using the following code to add a circle to my map!
// A function to draw a cricle
function drawCircle(lng,lat) {
var Clng = Clat/Math.cos(lat*d2r);
var Cpoints = [];
for (var i=0; i < 33; i++) {
var theta = Math.PI * (i/16);
Cx = lng + (Clng * Math.cos(theta));
Cy = lat + (Clat * Math.sin(theta));
Cpoints.push(new GPoint(Cx,Cy));
};
map.addOverlay(new GPolyline(Cpoints,Ccolor,Cwidth));
}
Now I was wondering if there is a way to check if this circle already
exists, so that it can not be added twice or more.
I also use:
map.removeOverlay(map.overlays[map.overlays.length-1]);
to remove the circle.
But basically I just want to toggle the circle on and off using one
link in the html code.
You can find the test page at:
http://www.tidakapapa.com/google_map_komodo_test3.en.php
Many thanks for any hints
:-) Dirk
0 Comments:
Yorum Gönder
<< Home