- Timestamp:
- Apr 16, 2010, 12:52:27 AM (15 years ago)
- Location:
- trunk/src/map/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/map/inc/nodemapWL.js
r7767 r7778 9 9 var overNode; 10 10 11 11 12 //This function is called from index.php 12 13 function initialize_map() { … … 18 19 map.setCenter(new GLatLng(52.162687, 4.493294), 11); 19 20 map.setUIToDefault(); 21 20 22 21 23 //Go through the array 'markers' (Declared in index.php) and add a marker for each marker stored in the array using our addMarker function … … 26 28 27 29 GEvent.addListener(map, "click", function() { 30 31 32 28 33 if(!overNode == true) 29 34 deSelect(); … … 46 51 function addMarker(current, i) { 47 52 var id = current.id; 48 var marker = new GMarker(new GLatLng(current.latitude[0], current.longitude[0]), {title: current.name[0]}) ;53 var marker = new GMarker(new GLatLng(current.latitude[0], current.longitude[0]), {title: current.name[0]}) ; 49 54 //Added mouseover listener that calls on our mouseOver function when the mouse moves over a marker on the map 50 55 GEvent.addListener(marker, 'mouseover', function() { 51 mouseOverNode(current.id, current.name[0]); 56 mouseOverNode(current.id, current.name[0],52.162687, 4.493294); 57 //mouseOverNode(current.id, current.name[0],current.latitude[0], current.longitude[0]); 52 58 }); 53 59 GEvent.addListener(marker, 'click', function() { … … 67 73 { 68 74 selected = true; 75 map.removeOverlay(polygon); 69 76 loadXMLDoc("inc/node_info.php?type=single"); 70 77 /* 71 78 *Hieronder verdergaan met dekking 72 79 */ 80 81 82 73 83 74 84 } 75 85 //Our mouseover function for single nodes. Gives the ID(our own given ID) and the name of the node. 76 function mouseOverNode(id, name )86 function mouseOverNode(id, name, lat, long) 77 87 { 78 88 if(!selected == true) 79 89 { 80 90 overNode = true; 91 92 //alert(lat); 93 94 81 95 loadXMLDoc("inc/node_info.php?type=single&name="+name+""); 82 96 /* 83 97 *Hieronder verdergaan met dekking 84 98 */ 99 drawCircle(lat, long, 2.0, "#6C3", 1, 0.75, "#0F0",.2); 100 101 102 103 104 105 106 107 85 108 86 109 } … … 90 113 { 91 114 overNode = false; 115 map.removeOverlay(polygon); 116 92 117 } 93 118 … … 206 231 } 207 232 } 233 234 235 236 237 -
trunk/src/map/inc/overlay.js
r7759 r7778 1 var map; 2 var marker; 3 var lat; 4 var lon; 5 var latOffset; 6 var lonOffset; 7 var polygon; 8 var pos; 9 var point; 10 var range = 500; 1 function 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 } 11 15 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 16 polygon = new GPolygon(Cpoints, strokeColor, strokeWidth, strokeOpacity, fillColor, fillOpacity); 17 map.addOverlay(polygon); 18 }
Note:
See TracChangeset
for help on using the changeset viewer.