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

Last change on this file since 7757 was 7751, checked in by bvdvelde, 15 years ago

Wanneer de marker verplaatst verplaatst de cirkel nu mee. Cirkel vraagt de locatie van de marker op voor de positie van hemzelf.

File size: 2.9 KB
Line 
1var map;
2var marker;
3var lat;
4var lon;
5var latOffset;
6var lonOffset;
7var polygon;
8var pos;
9var point;
10var range = 500;
11
12 function nodeAdd() {
13 if (GBrowserIsCompatible()) {
14 map = new GMap2(document.getElementById("mapcanvas"));
15 map.setCenter(new GLatLng(52.162687, 4.493294), 14);
16 map.setUIToDefault();
17
18 marker = new GMarker(new GLatLng(52.165700, 4.483499));
19 GEvent.addListener(marker, "click", function () {
20 marker.openInfoWindowHtml("Test, Test, You suck! Eindelijk, het werkt!!!!");
21 });
22
23 //Added mouseover listener that calls on our mouseOver function when the mouse moves over a marker on the map
24 GEvent.addListener(marker, "mouseover", function() {
25 map.addOverlay(cirkel);;
26 });
27
28 GEvent.addListener(marker, "mouseout", function() {
29 map.removeOverlay(cirkel);
30 });
31
32
33
34
35 GPolygon.Shape = function(point,r1,r2,r3,r4,rotation,vertexCount, strokeColour,strokeWeight,Strokepacity,fillColour,fillOpacity,opts,tilt) {
36 var rot = -rotation*Math.PI/180;
37 var points = [];
38 var latConv = point.distanceFrom(new GLatLng(point.lat()+0.1,point.lng()))*10;
39 var lngConv = point.distanceFrom(new GLatLng(point.lat(),point.lng()+0.1))*10;
40 var step = (360/vertexCount)||10;
41
42 var flop = -1;
43 if (tilt) {
44 var I1=180/vertexCount;
45 } else {
46 var I1=0;
47 }
48 for(var i=I1; i<=360.001+I1; i+=step) {
49 var r1a = flop?r1:r3;
50 var r2a = flop?r2:r4;
51 flop = -1-flop;
52 var y = r1a * Math.cos(i * Math.PI/180);
53 var x = r2a * Math.sin(i * Math.PI/180);
54 var lng = (x*Math.cos(rot)-y*Math.sin(rot))/lngConv;
55 var lat = (y*Math.cos(rot)+x*Math.sin(rot))/latConv;
56
57 points.push(new GLatLng(point.lat()+lat,point.lng()+lng));
58 }
59 return (new GPolygon(points,strokeColour,strokeWeight,Strokepacity,fillColour,fillOpacity,opts))
60 }
61
62 GPolygon.Circle = function(point,radius,strokeColour,strokeWeight,Strokepacity,fillColour,fillOpacity,opts) {
63 return GPolygon.Shape(point,radius,radius,radius,radius,0,100,strokeColour,strokeWeight,Strokepacity,fillColour,fillOpacity,opts)
64 }
65
66 // http://econym.org.uk/gmap/eshapes.htm voorbeeld.
67 // de locatie van de cirkel
68
69
70 // locatie, doorsnee (in meters), kleur omtrek, dikte omtrek, doorzichtigheid opvulling, kleur opvulling, doorzichtigheid.
71 map.addOverlay(marker);
72 cirkel = new GPolygon.Circle(marker.getLatLng(),range,"#000000",1,1,"#00ff00",0.5)
73
74 }
75 }
76
77 //Our mouseover function
78 /*function mouseOver(dekking)
79 {
80 //For now we only post the id(We made ourself in kmlHandler) and the name of the node
81 map.addOverlay(GPolygon.Circle(point,500,"#000000",1,1,"#00ff00",0.5));
82 //We will replace this function with a httprequest to a php file in the future
83 }
84 */
85
86
87
88
89
90
91
92
Note: See TracBrowser for help on using the repository browser.