OpenLayers OpenLayers

Changeset 5427

Show
Ignore:
Timestamp:
12/15/07 03:07:20 (1 year ago)
Author:
crschmidt
Message:

Add examples for each format.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/crschmidt/projection/examples/convert-data.html

    r5426 r5427  
    7272            }; 
    7373        } 
     74        function updateExamples() { 
     75            examples = { 
     76'geojson':['GeoJSON', '{"type": "LineString", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }'], 
     77'wkt':['WKT','LINESTRING(100 0, 101 1)'], 
     78'gml':['GML','<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs"><gml:featureMember xmlns:gml="http://www.opengis.net/gml"><feature:features xmlns:feature="http://mapserver.gis.umn.edu/mapserver" fid="OpenLayers.Feature.Vector_18"><feature:geometry><gml:LineString><gml:coordinates decimal="." cs=", " ts=" ">100, 0 101, 1</gml:coordinates></gml:LineString></feature:geometry></feature:features></gml:featureMember></wfs:FeatureCollection>'], 
     79'georss':['GeoRSS','<item xmlns="http://backend.userland.com/rss2"><title></title><description></description><georss:line xmlns:georss="http://www.georss.org/georss">0 100 1 101</georss:line></item>'], 
     80'kml':['KML','<kml xmlns="http://earth.google.com/kml/2.0"><Folder><name>OpenLayers export</name><description>Exported on Sat Dec 15 2007 02:55:27 GMT-0500 (EST)</description><Placemark><name>OpenLayers.Feature.Vector_30</name><description>No description available</description><LineString><coordinates>100, 0 101, 1</coordinates></LineString></Placemark></Folder></kml>'] 
     81            } 
     82            var in_type = document.getElementById("in_formatType").value; 
     83            var ex = OpenLayers.Util.getElement("example_area"); 
     84            var th = OpenLayers.Util.getElement("type_head"); 
     85            th.innerHTML = examples[in_type][0]; 
     86            var str = examples[in_type][1];  
     87            str = str.replace(/>/g, '>\n'); 
     88            ex.value = str; 
     89        }     
    7490 
    7591        function deserialize() { 
     
    87103    </script> 
    88104  </head> 
    89   <body onload="updateFormats()"> 
     105  <body onload="updateFormats(); updateExamples();"> 
    90106    <div id="leftcol"> 
    91107        <h1 id="title">OpenLayers Format Conversion</h1> 
     
    101117            for vector features. Convert data by pasting the text representation below.</p> 
    102118            <label for="in_formatType">Input Format</label> 
    103             <select name="in_formatType" id="in_formatType"
     119            <select name="in_formatType" id="in_formatType" onchange="updateExamples()"
    104120                <option value="geojson" selected="selected">GeoJSON</option> 
    105121                <option value="kml">KML</option> 
     
    134150            <br /> 
    135151            <input type="button" value="Convert" onclick="deserialize();" /> 
    136         </div> 
     152            <h3><span id="type_head"></span> Example</h3> 
     153            <textarea id="example_area" style="width:100%" rows="10"></textarea> 
    137154 
    138         <div id="docs"> 
    139         </div> 
     155 </div> 
    140156 
    141157    </div>