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

Last change on this file since 7732 was 7710, checked in by bvdvelde, 15 years ago

Nu met een cirkel + doorzichte opvulling - voorbeeld was direct gekopieerd, moet het nog héél goed bekijken op functie & copyrights.

File size: 2.1 KB
RevLine 
[7703]1var map;
[7707]2var marker;
3var lat;
4var lon;
5var latOffset;
6var lonOffset;
7var polygon;
[7710]8var pos;
9var point;
[7703]10
[7710]11/*
12 function nodeAdd() {
[7707]13 if (GBrowserIsCompatible()) {
[7703]14 map = new GMap2(document.getElementById("mapcanvas"));
[7707]15 map.setCenter(new GLatLng(52.162687, 4.493294), 12);
[7703]16 map.setUIToDefault();
[7710]17
[7707]18 marker = new GMarker(map.getCenter());
19 GEvent.addListener(marker, "click", function () {
20 marker.openInfoWindowHtml("Test, Test, You suck! Eindelijk, het werkt!!!!");
21 });
[7710]22
23
24
25
26 GPolygon.Shape = function(point,r1,r2,r3,r4,rotation,vertexCount, strokeColour,strokeWeight,Strokepacity,fillColour,fillOpacity,opts,tilt) {
27 var rot = -rotation*Math.PI/180;
28 var points = [];
29 var latConv = point.distanceFrom(new GLatLng(point.lat()+0.1,point.lng()))*10;
30 var lngConv = point.distanceFrom(new GLatLng(point.lat(),point.lng()+0.1))*10;
31 var step = (360/vertexCount)||10;
32
33 var flop = -1;
34 if (tilt) {
35 var I1=180/vertexCount;
36 } else {
37 var I1=0;
38 }
39 for(var i=I1; i<=360.001+I1; i+=step) {
40 var r1a = flop?r1:r3;
41 var r2a = flop?r2:r4;
42 flop = -1-flop;
43 var y = r1a * Math.cos(i * Math.PI/180);
44 var x = r2a * Math.sin(i * Math.PI/180);
45 var lng = (x*Math.cos(rot)-y*Math.sin(rot))/lngConv;
46 var lat = (y*Math.cos(rot)+x*Math.sin(rot))/latConv;
47
48 points.push(new GLatLng(point.lat()+lat,point.lng()+lng));
49 }
50 return (new GPolygon(points,strokeColour,strokeWeight,Strokepacity,fillColour,fillOpacity,opts))
51 }
52
53 GPolygon.Circle = function(point,radius,strokeColour,strokeWeight,Strokepacity,fillColour,fillOpacity,opts) {
54 return GPolygon.Shape(point,radius,radius,radius,radius,0,100,strokeColour,strokeWeight,Strokepacity,fillColour,fillOpacity,opts)
55 }
56
57 // http://econym.org.uk/gmap/eshapes.htm voorbeeld.
58 var point = new GLatLng(52.162687, 4.493294);
59 map.addOverlay(GPolygon.Circle(point,500,"#000000",1,1,"#00ff00",0.5));
[7707]60 map.addOverlay(marker);
61
62 }
[7703]63 }
[7710]64
65 */
66
67
68
69
[7707]70
Note: See TracBrowser for help on using the repository browser.