georss.rst 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. .. _tutorials_georss:
  2. GeoRSS
  3. ======
  4. GeoServer supports `GeoRSS <http://georss.org/>`_ as an output format allowing you to serve features as an RSS feed.
  5. Quick Start
  6. -----------
  7. If you are using a web browser which can render RSS feeds simply visit the URL `http://localhost:8080/geoserver/wms/reflect?layers=states&format=rss <http://localhost:8080/geoserver/wms/reflect?layers=states&format=rss>`_ in your browser. This is assuming a local GeoServer instance is running with an out of the box configuration. You should see a result that looks more or less like this:
  8. .. figure:: browser.png
  9. :align: center
  10. *topp:states rss feed*
  11. Templating
  12. ----------
  13. GeoServer uses FreeMarker templates to customize the returned GeoRSS feed. If you are not familiar with FreeMarker templates you may wish to read the :ref:`tutorial_freemarkertemplate` tutorial, and the :ref:`getutorial_kmlplacemark` page, which has simple examples.
  14. Three template files are currently supported:
  15. * ``title.ftl``
  16. * ``description.ftl``
  17. * ``link.ftl``
  18. Each of these files may be used to customize the associated field in the GeoRSS feed.
  19. Ajax Map Mashups
  20. ----------------
  21. .. note::
  22. For Ajax map mashups to work, the GeoServer instance must be visible to the Internet (i.e. using the address ``localhost`` will not work).
  23. Google Maps
  24. -----------
  25. How to create a Google Maps mashup with a GeoRSS overlay produced by GeoServer.
  26. #. Obtain a `Google Maps API Key <http://www.google.com/apis/maps/signup.html>`_ from Google.
  27. #. Create an html file called ``gmaps.html``::
  28. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org R/xhtml1/DTD/xhtml1-strict.dtd">
  29. <html xmlns="http://www.w3.org/1999/xhtml">
  30. <head>
  31. <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  32. <title>Google Maps JavaScript API Example< itle>
  33. <script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=<INSERT MAPS API KEY HERE>" type="text/javascript"></script>
  34. <script type="text/javascript">
  35. //<![CDATA[
  36. function load() {
  37. if (GBrowserIsCompatible()) {
  38. var map = new GMap2(document.getElementById("map"));
  39. map.addControl(new GLargeMapControl());
  40. map.setCenter(new GLatLng(40,-98), 4);
  41. var geoXml = new GGeoXml("<INSERT GEOSERVER URL HERE>/geoserver/wms/reflect?layers=states&format=rss");
  42. map.addOverlay(geoXml);
  43. }
  44. }
  45. //]]>
  46. </script>
  47. </head>
  48. <body onload="load()" onunload="GUnload()">
  49. <div id="map" style="width: 800px; height: 600px"></div>
  50. </body>
  51. </html>
  52. #. Visit ``gmaps.html`` in your web browser.
  53. .. note::
  54. The version of the google maps api must be **2.x**, and not just **2** You must insert your specific maps api key, and geoserver base url
  55. Yahoo Maps
  56. ----------
  57. How to create a Yahoo! Maps mashup with a GeoRSS overlay produced by GeoServer.
  58. #. Obtain a <Yahoo Maps Application ID <http://search.yahooapis.com/webservices/register_application>`_ from Yahoo.
  59. #. Create an html file called ``ymaps.html``::
  60. <html>
  61. <head>
  62. <title>Yahoo! Maps GeoRSS Overlay Example< itle>
  63. <script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=<INSERT APPLICATION ID HERE>" type="text/javascript"></script>
  64. <script type="text/javascript" language="JavaScript">
  65. function StartYMap() {
  66. var map = new YMap(document.getElementById('ymap'));
  67. map.addPanControl();
  68. map.addZoomShort();
  69. function doStart(eventObj) {
  70. var defaultEventObject = eventObj;
  71. //eventObj.ThisMap [map object]
  72. //eventObj.URL [argument]
  73. //eventObj.Data [processed input]
  74. }
  75. function doEnd(eventObj) {
  76. var defaultEventObject = eventObj;
  77. //eventObj.ThisMap [map object]
  78. //eventObj.URL [argument]
  79. //eventObj.Data [processed input]
  80. map.smoothMoveByXY(new YCoordPoint(10,50));
  81. }
  82. YEvent.Capture(map,EventsList.onStartGeoRSS, function(eventObj) { doStart(eventObj); });
  83. YEvent.Capture(map,EventsList.onEndGeoRSS, function(eventObj) { doEnd(eventObj); });
  84. map.addOverlay(new YGeoRSS('http://<INSERT GEOSERVER URL HERE>/geoserver/wms/reflect?layers=states&format=rss'));
  85. }
  86. window.onload = StartYMap;
  87. </script>
  88. </head>
  89. <body>
  90. <div id="ymap" style="width: 800px; height: 600px; left:2px; top:2px"></div>
  91. </body>
  92. </html>
  93. #. Visit ``ymaps.html`` in your web browser.
  94. .. note::
  95. The version of the yahoo maps api must be **3.0** You must insert your specific application id, and geoserver base url
  96. Microsoft Virtual Earth
  97. -----------------------
  98. .. note::
  99. Non Internet Explorer Users*: GeoRSS overlays are only supported in Internet Explorer, versions greater than 5.5.
  100. How to create a Microsoft Virtual Earth mashup with a GeoRSS overlay produced by GeoServer.
  101. .. note::
  102. To access a GeoRSS feed from Microsoft Virtual Earth the file (ve.html) must be accessed from a Web Server, IE. It will not work if run from local disk.
  103. #. Create an html file called ``ve.html``. **Note**: You must insert your specific maps api key, and geoserver base url::
  104. <html>
  105. <head>
  106. <script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"></script>
  107. <script>
  108. var map;
  109. function OnPageLoad()
  110. {
  111. map = new VEMap('map');
  112. map.LoadMap();
  113. var veLayerSpec = new VELayerSpecification();
  114. veLayerSpec.Type = VELayerType.GeoRSS;
  115. veLayerSpec.ID = 'Hazards';
  116. veLayerSpec.LayerSource = 'http://<INSERT GEOSERVER URL HERE>/geoserver/wms/reflect?layers=states&format=rss';
  117. veLayerSpec.Method = 'get';
  118. map.AddLayer(veLayerSpec);
  119. }
  120. </script>
  121. </head>
  122. <body onload="OnPageLoad();">
  123. <div id="map" style="position:relative;width:800px;height:600px;"></div>
  124. </body>
  125. </html>
  126. #. Visit ``ve.html`` in your web browser. You should see the following:
  127. .. figure:: ve.png
  128. :align: center
  129. *Virtual Earth*