source: trunk/src/map/inc/overlay.js@ 7833

Last change on this file since 7833 was 7833, checked in by ddboer, 16 years ago

Clusters now get a red highlight behind them

File size: 1.7 KB
Line 
1function 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
24function highlightCurrentMarker(markerPoint){
25//var markerPoint = currentMarker.getPoint();
26
27var polyPoints = Array();
28
29if (highlightCircle) {
30 map.removeOverlay(highlightCircle);
31}
32
33var mapNormalProj = G_NORMAL_MAP.getProjection();
34var mapZoom = map.getZoom();
35var clickedPixel = mapNormalProj.fromLatLngToPixel(markerPoint, mapZoom);
36
37var polySmallRadius = 20;
38
39var polyNumSides = 20;
40var polySideLength = 18;
41
42for (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?)
52highlightCircle = new GPolygon(polyPoints,"#000000",2,0.0,"#DF0101",.5);
53map.addOverlay(highlightCircle);
54}
Note: See TracBrowser for help on using the repository browser.