1 | function drawCircle(lat, lng, radius, strokeColor, strokeWidth, strokeOpacity, fillColor, fillOpacity) {
|
---|
2 |
|
---|
3 | var d2r = Math.PI/180;
|
---|
4 | var r2d = 180/Math.PI;
|
---|
5 | var Clat = radius * 0.0089437672; // Convert statute kilometers into degrees latitude
|
---|
6 | var Clng = Clat/Math.cos(lat*d2r);
|
---|
7 | var Cpoints = [];
|
---|
8 | for (var i=0; i < 33; i++) {
|
---|
9 | var theta = Math.PI * (i/16);
|
---|
10 | Cy = lat + (Clat * Math.sin(theta));
|
---|
11 | Cx = lng + (Clng * Math.cos(theta));
|
---|
12 | var P = new GLatLng(Cy, Cx);
|
---|
13 | Cpoints.push(P);
|
---|
14 | }
|
---|
15 |
|
---|
16 | polygon = new GPolygon(Cpoints, strokeColor, strokeWidth, strokeOpacity, fillColor, fillOpacity);
|
---|
17 |
|
---|
18 |
|
---|
19 | return polygon;
|
---|
20 | }
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 | function highlightCurrentMarker(){
|
---|
25 | var markerPoint = currentMarker.getPoint();
|
---|
26 |
|
---|
27 | var polyPoints = Array();
|
---|
28 |
|
---|
29 | if (highlightCircle) {
|
---|
30 | map.removeOverlay(highlightCircle);
|
---|
31 | }
|
---|
32 |
|
---|
33 | var mapNormalProj = G_NORMAL_MAP.getProjection();
|
---|
34 | var mapZoom = map.getZoom();
|
---|
35 | var clickedPixel = mapNormalProj.fromLatLngToPixel(markerPoint, mapZoom);
|
---|
36 |
|
---|
37 | var polySmallRadius = 20;
|
---|
38 |
|
---|
39 | var polyNumSides = 20;
|
---|
40 | var polySideLength = 18;
|
---|
41 |
|
---|
42 | for (var a = 0; a<(polyNumSides+1); a++) {
|
---|
43 | var aRad = polySideLength*a*(Math.PI/180);
|
---|
44 | var polyRadius = polySmallRadius;
|
---|
45 | var pixelX = clickedPixel.x + polyRadius * Math.cos(aRad);
|
---|
46 | var pixelY = clickedPixel.y + polyRadius * Math.sin(aRad);
|
---|
47 | var polyPixel = new GPoint(pixelX,pixelY);
|
---|
48 | var polyPoint = mapNormalProj.fromPixelToLatLng(polyPixel,mapZoom);
|
---|
49 | polyPoints.push(polyPoint);
|
---|
50 | }
|
---|
51 | // Using GPolygon(points, strokeColor?, strokeWeight?, strokeOpacity?, fillColor?, fillOpacity?)
|
---|
52 | highlightCircle = new GPolygon(polyPoints,"#000000",2,0.0,"#F7FE2E",.5);
|
---|
53 | map.addOverlay(highlightCircle);
|
---|
54 | }
|
---|