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

Last change on this file since 7747 was 7740, checked in by bvdvelde, 16 years ago

Cirkel word toegevoegd met mouseOver en verwijdered met mouseOut = Blije Bart! Het werkt!

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), 12);
16 map.setUIToDefault();
17
18 marker = new GMarker(map.getCenter());
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 var point = new GLatLng(52.162687, 4.493294);
69 // locatie, doorsnee (in meters), kleur omtrek, dikte omtrek, doorzichtigheid opvulling, kleur opvulling, doorzichtigheid.
70 map.addOverlay(marker);
71 cirkel = new GPolygon.Circle(point,range,"#000000",1,1,"#00ff00",0.5)
72
73 }
74 }
75
76 //Our mouseover function
77 /*function mouseOver(dekking)
78 {
79 //For now we only post the id(We made ourself in kmlHandler) and the name of the node
80 map.addOverlay(GPolygon.Circle(point,500,"#000000",1,1,"#00ff00",0.5));
81 //We will replace this function with a httprequest to a php file in the future
82 }
83 */
84
85
86
87
88
89
90
91
Note: See TracBrowser for help on using the repository browser.