default.wiki 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <script src="http://openlayers.org/api/OpenLayers.js"></script>
  2. <script src="http://openstreetmap.org/openlayers/OpenStreetMap.js"></script>
  3. <script type="text/javascript">
  4. function make_remove_closure(id) {
  5. var elem = document.getElementById(id);
  6. return function(evt) {
  7. elem.parentElement.removeChild(elem);
  8. };
  9. }
  10. function display_map(div_id, query_url, lat, lon, zoom) {
  11. map = new OpenLayers.Map(div_id, {
  12. controls:[
  13. new OpenLayers.Control.Navigation(),
  14. new OpenLayers.Control.PanZoomBar(),
  15. new OpenLayers.Control.LayerSwitcher(),
  16. new OpenLayers.Control.Attribution()],
  17. maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
  18. maxResolution: 156543.0399,
  19. numZoomLevels: 19,
  20. units: 'm',
  21. projection: new OpenLayers.Projection("EPSG:900913"),
  22. displayProjection: new OpenLayers.Projection("EPSG:4326")
  23. } );
  24. layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
  25. map.addLayer(layerMapnik);
  26. var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
  27. map.setCenter (lonLat, zoom);
  28. //Initialise the vector layer using OpenLayers.Format.OSM
  29. var styleMap = new OpenLayers.StyleMap({
  30. strokeColor: "blue",
  31. strokeWidth: 10,
  32. pointRadius: 20,
  33. fillColor: "blue"
  34. });
  35. var layer = new OpenLayers.Layer.Vector("Polygon", {
  36. strategies: [new OpenLayers.Strategy.Fixed()],
  37. protocol: new OpenLayers.Protocol.HTTP({
  38. url: query_url,
  39. format: new OpenLayers.Format.OSM()
  40. }),
  41. styleMap: styleMap,
  42. projection: new OpenLayers.Projection("EPSG:4326")
  43. });
  44. layer.events.register("featuresadded", layer,
  45. make_remove_closure(div_id + "_progressbar"));
  46. map.addLayers([layer]);
  47. return map;
  48. }
  49. var maps = new Array();
  50. function init(){
  51. var map_hooks = document.forms;
  52. for (var i in map_hooks)
  53. {
  54. if (map_hooks[i].getAttribute("class") == "map_descriptor")
  55. maps.push(display_map
  56. (map_hooks[i].getAttribute("action"),
  57. map_hooks[i].url.value,
  58. map_hooks[i].lat.value, map_hooks[i].lon.value,
  59. map_hooks[i].zoom.value));
  60. }
  61. }
  62. </script>
  63. <h1>{{{count}}} results found</h1>
  64. {{node:
  65. <div style="min-height:300px;">
  66. {{coords:<div id="map_node_{{{id}}}" style="width:300px;height:300px;float:right;">
  67. <div id="map_node_{{{id}}}_progressbar">Loading data ...</div>
  68. <form class="map_descriptor" action="map_node_{{{id}}}">
  69. <input type="hidden" name="url" value="interpreter?data=node%28{{{id}}}%29%3Bout+skel%3B"/>
  70. <input type="hidden" name="lat" value="{{{lat}}}"/>
  71. <input type="hidden" name="lon" value="{{{lon}}}"/>
  72. <input type="hidden" name="zoom" value="17"/>
  73. </form>
  74. </div>}}
  75. <p>Node <strong>{{{id}}}</strong>,{{coords: lat: {{{lat}}}, lon: {{{lon}}},}}<br/>
  76. {{tags:{{{key}}} = {{{value}}}<br/>
  77. }}
  78. <a href="http://www.openstreetmap.org/browse/node/{{{id}}}">Browse on openstreetmap.org</a></p>
  79. </div>
  80. }}
  81. {{way:
  82. <div style="min-height:300px;">
  83. {{bbox:<div id="map_way_{{{id}}}" style="width:300px;height:300px;float:right;">
  84. <div id="map_way_{{{id}}}_progressbar">Loading data ...</div>
  85. <form class="map_descriptor" action="map_way_{{{id}}}">
  86. <input type="hidden" name="url" value="interpreter?data=%28way%28{{{id}}}%29%3Bnode%28w%29%29%3Bout+skel%3B"/>
  87. <input type="hidden" name="lat" value="{{{lat}}}"/>
  88. <input type="hidden" name="lon" value="{{{lon}}}"/>
  89. <input type="hidden" name="zoom" value="{{{zoom}}}"/>
  90. </form>
  91. </div>{{none:}}}}
  92. <p>Way <strong>{{{id}}}</strong>,{{bbox:{{none: no geographic reference}} bounding box south: {{{south}}}, west: {{{west}}}, north: {{{north}}}, east: {{{east}}},}}<br/>
  93. {{tags:{{{key}}} = {{{value}}}<br/>
  94. }}{{members:{{first: members: {{{ref}}}}}, {{{ref}}}}}<br/>
  95. <a href="http://www.openstreetmap.org/browse/way/{{{id}}}">Browse on openstreetmap.org</a></p>
  96. </div>
  97. }}
  98. {{relation:
  99. <div style="min-height:300px;">
  100. {{bbox:<div id="map_relation_{{{id}}}" style="width:300px;height:300px;float:right;">
  101. <div id="map_relation_{{{id}}}_progressbar">Loading data ...</div>
  102. <form class="map_descriptor" action="map_relation_{{{id}}}">
  103. <input type="hidden" name="url" value="interpreter?data=%28relation%28{{{id}}}%29%3Bnode%28r%29%2D%3E%2Ex%3Bway%28r%29%3Bnode%28w%29%3B%29%3Bout+skel%3B"/>
  104. <input type="hidden" name="lat" value="{{{lat}}}"/>
  105. <input type="hidden" name="lon" value="{{{lon}}}"/>
  106. <input type="hidden" name="zoom" value="{{{zoom}}}"/>
  107. </form>
  108. </div>{{none:}}}}
  109. <p>Relation <strong>{{{id}}}</strong>,{{bbox:{{none: no geographic reference}} bounding box south: {{{south}}}, west: {{{west}}}, north: {{{north}}}, east: {{{east}}},}}<br/>
  110. {{tags:{{{key}}} = {{{value}}}<br/>
  111. }}{{members:{{first: members: {{{type}}} <strong>{{{ref}}}</strong> &quot;{{{role}}}&quot;}}, {{{type}}} <strong>{{{ref}}}</strong> &quot;{{{role}}}&quot;}}<br/>
  112. <a href="http://www.openstreetmap.org/browse/relation/{{{id}}}">Browse on openstreetmap.org</a></p>
  113. </div>
  114. }}