| 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(markerPoint){
|
|---|
| 25 |
|
|---|
| 26 | var polyPoints = Array();
|
|---|
| 27 |
|
|---|
| 28 | if (highlightCircle) {
|
|---|
| 29 | map.removeOverlay(highlightCircle);
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | var mapNormalProj = G_NORMAL_MAP.getProjection();
|
|---|
| 33 | var mapZoom = map.getZoom();
|
|---|
| 34 | var clickedPixel = mapNormalProj.fromLatLngToPixel(markerPoint, mapZoom);
|
|---|
| 35 |
|
|---|
| 36 | var polySmallRadius = 20;
|
|---|
| 37 |
|
|---|
| 38 | var polyNumSides = 20;
|
|---|
| 39 | var polySideLength = 18;
|
|---|
| 40 |
|
|---|
| 41 | for (var a = 0; a<(polyNumSides+1); a++) {
|
|---|
| 42 | var aRad = polySideLength*a*(Math.PI/180);
|
|---|
| 43 | var polyRadius = polySmallRadius;
|
|---|
| 44 | var pixelX = clickedPixel.x + polyRadius * Math.cos(aRad);
|
|---|
| 45 | var pixelY = clickedPixel.y + polyRadius * Math.sin(aRad);
|
|---|
| 46 | var polyPixel = new GPoint(pixelX,pixelY);
|
|---|
| 47 | var polyPoint = mapNormalProj.fromPixelToLatLng(polyPixel,mapZoom);
|
|---|
| 48 | polyPoints.push(polyPoint);
|
|---|
| 49 | }
|
|---|
| 50 | // Using GPolygon(points, strokeColor?, strokeWeight?, strokeOpacity?, fillColor?, fillOpacity?)
|
|---|
| 51 | highlightCircle = new GPolygon(polyPoints,"#000000",2,0.0,"#DF0101",.5);
|
|---|
| 52 | map.addOverlay(highlightCircle);
|
|---|
| 53 |
|
|---|
| 54 | return markerPoint;
|
|---|
| 55 | }
|
|---|