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

Last change on this file since 7767 was 7759, checked in by bvdvelde, 15 years ago

Voegt een cirkel toe wanneer er op een node geklikt wordt... nog voor verandering vatbaar, ligt eraan hoe het selecteren gemaakt word en op het moment wanneer de gebruiker mouseover & klikt staan er 2 cirkels (dubbele opacity).

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 //mouseout listener that removes the cirkel once the user moves his mouse off the designated marker
29 GEvent.addListener(marker, "mouseout", function() {
30 map.removeOverlay(cirkel);
31 });
32
33 //adds a cirkel when the user clicks on the marker
34 GEvent.addListener(marker, "click", function() {
35 map.addOverlay(cirkel1);
36 });
37
38
39 GPolygon.Shape = function(point,r1,r2,r3,r4,rotation,vertexCount, strokeColour,strokeWeight,Strokepacity,fillColour,fillOpacity,opts,tilt) {
40 var rot = -rotation*Math.PI/180;
41 var points = [];
42 var latConv = point.distanceFrom(new GLatLng(point.lat()+0.1,point.lng()))*10;
43 var lngConv = point.distanceFrom(new GLatLng(point.lat(),point.lng()+0.1))*10;
44 var step = (360/vertexCount)||10;
45
46 var flop = -1;
47 if (tilt) {
48 var I1=180/vertexCount;
49 } else {
50 var I1=0;
51 }
52 for(var i=I1; i<=360.001+I1; i+=step) {
53 var r1a = flop?r1:r3;
54 var r2a = flop?r2:r4;
55 flop = -1-flop;
56 var y = r1a * Math.cos(i * Math.PI/180);
57 var x = r2a * Math.sin(i * Math.PI/180);
58 var lng = (x*Math.cos(rot)-y*Math.sin(rot))/lngConv;
59 var lat = (y*Math.cos(rot)+x*Math.sin(rot))/latConv;
60
61 points.push(new GLatLng(point.lat()+lat,point.lng()+lng));
62 }
63 return (new GPolygon(points,strokeColour,strokeWeight,Strokepacity,fillColour,fillOpacity,opts))
64 }
65
66 GPolygon.Circle = function(point,radius,strokeColour,strokeWeight,Strokepacity,fillColour,fillOpacity,opts) {
67 return GPolygon.Shape(point,radius,radius,radius,radius,0,100,strokeColour,strokeWeight,Strokepacity,fillColour,fillOpacity,opts)
68 }
69
70 // http://econym.org.uk/gmap/eshapes.htm voorbeeld.
71 // de locatie van de cirkel
72
73
74 // locatie, doorsnee (in meters), kleur omtrek, dikte omtrek, ??, kleur opvulling, doorzichtigheid.
75 map.addOverlay(marker);
76 cirkel = new GPolygon.Circle(marker.getLatLng(),range,"#000000",0,1,"#00ff00",0.5)
77 cirkel1 = new GPolygon.Circle(marker.getLatLng(),range,"#000000",0,1,"#00ff00",0.5)
78
79 }
80 }
81
82
83
84
85
86
87
88
Note: See TracBrowser for help on using the repository browser.