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

Last change on this file since 7858 was 7834, checked in by ddboer, 15 years ago

Zoom works

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