Changeset 8304 in genesis
- Timestamp:
- Aug 10, 2010, 7:18:58 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
nodes/nodemap.html
r8303 r8304 15 15 16 16 <script> 17 var map, rulerControl; 17 var url_pal3 = "http://maps.google.com/mapfiles/kml/pal3/"; 18 var map, rulerControl, clickControl; 18 19 var mapnik, wms; 19 20 var projection_wgs = new OpenLayers.Projection("EPSG:4326"); // WGS 1984 … … 23 24 var max_opacity = 0.9; 24 25 var min_opacity = 0.1; 26 27 OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { 28 defaultHandlerOptions: { 29 'single': true, 30 'double': false, 31 'pixelTolerance': 0, 32 'stopSingle': false, 33 'stopDouble': false 34 }, 35 36 initialize: function(options) { 37 this.handlerOptions = OpenLayers.Util.extend( 38 {}, this.defaultHandlerOptions 39 ); 40 OpenLayers.Control.prototype.initialize.apply( 41 this, arguments 42 ); 43 this.handler = new OpenLayers.Handler.Click( 44 this, { 45 'click': this.trigger 46 }, this.handlerOptions 47 ); 48 }, 49 50 trigger: function(e) { 51 var lonlat = map.getLonLatFromViewPortPx(e.xy); 52 lonlat = lonlat.transform( projection_smp, projection_wgs); 53 var url = coordConvert(lonlat.lon, lonlat.lat); 54 alert("You clicked near " + lonlat.lon + " N, " + 55 + lonlat.lat + " E\n\n" + 56 'Copy/paste URL in NEW browser window to get your RDNAP coordinates\n\n' + url); 57 } 58 59 }); 25 60 26 61 … … 95 130 select.activate(); 96 131 132 clickControl = new OpenLayers.Control.Click(); 133 map.addControl(clickControl); 134 clickControl.deactivate(); 135 136 97 137 var vectors = new OpenLayers.Layer.Vector("Vector Layer") 98 138 map.addLayer(vectors); … … 105 145 map.addControl(new OpenLayers.Control.KeyboardDefaults()); 106 146 map.addControl(new OpenLayers.Control.ZoomBox()); 147 148 149 var selectCtrl = new OpenLayers.Control.SelectFeature(vectors, 150 {clickout: true} 151 ); 152 map.addControl(selectCtrl); 153 selectCtrl.activate(); 154 107 155 108 156 //var in_options = { … … 237 285 } 238 286 287 function toggleClickControl() { 288 if (!clickControl.active) { 289 clickControl.activate(); 290 document.getElementById('click').src = url_pal3 + "icon32.png"; 291 } else { 292 clickControl.deactivate(); 293 document.getElementById('click').src = url_pal3 + "icon28.png"; 294 295 } 296 } 297 239 298 function toggleRulerControl() { 240 299 if (!rulerControl.active) { … … 244 303 rulerControl.deactivate(); 245 304 document.getElementById('ruler').src = "ruler_off.png"; 246 document.getElementById('output').innerHTML = ""; 247 248 } 249 } 305 } 306 } 307 250 308 function defaultFocus() { 251 309 map.setCenter(new OpenLayers.LonLat(4.50,52.186) // Center of the map … … 263 321 } 264 322 323 function coordConvert(lam, phi) { 324 var lam_deg = Math.floor(lam); 325 var t = (lam - lam_deg) * 60; 326 var lam_min = Math.floor(t); 327 var lam_sec = (t - lam_min) * 60; 328 329 var phi_deg = Math.floor(phi); 330 var t = (phi - phi_deg) * 60; 331 var phi_min = Math.floor(t); 332 var phi_sec = (t - phi_min) * 60; 333 334 var url = "http://www.rdnap.nl/cgi-bin/rdetrs.pl?func=etrs2rd&h=0" + 335 "&lam_deg=" + lam_deg + 336 "&lam_min=" + lam_min + 337 "&lam_sec=" + lam_sec + 338 "&phi_deg=" + phi_deg + 339 "&phi_min=" + phi_min + 340 "&phi_sec=" + phi_sec 341 ; 342 return(url); 343 } 344 345 265 346 // http://openlayers.org/dev/examples/strategy-cluster-threshold.html 266 347 </script> … … 270 351 <div id="controller" style="position: absolute; top: 10px; left : 80px; z-index:1004"> 271 352 <img id="ruler" src="ruler_off.png" onClick="toggleRulerControl()" /> 272 <img height="22" src="http://maps.google.com/mapfiles/kml/pal3/icon20.png" alt="Reset focus" onclick="defaultFocus()"/> 273 <img height="22" src="http://maps.google.com/mapfiles/kml/pal3/icon36.png" alt="Information" onclick="toggleInfo()" /> 353 <img height="22" src="http://maps.google.com/mapfiles/kml/pal3/icon23.png" title="Reset focus" onclick="defaultFocus()"/> 354 <img height="22" src="http://maps.google.com/mapfiles/kml/pal3/icon36.png" title="Information" onclick="toggleInfo()" /> 355 <img id="click" height="22" src="http://maps.google.com/mapfiles/kml/pal3/icon28.png" title="Coordinate converter" onclick="toggleClickControl()" /> 274 356 <div id="output"></div> 275 357 </div>
Note:
See TracChangeset
for help on using the changeset viewer.