Hello Slawomir,<br><br>That&#39;s crafty! I didn&#39;t know you could do that trick (&quot;open(&#39;data:...&#39;)&quot;.  Good to know. :)<br><br>-z<br><br><div class="gmail_quote">On Fri, Jan 21, 2011 at 9:32 AM, Slawomir Messner <span dir="ltr">&lt;<a href="mailto:slawomir.messner@staff.uni-marburg.de">slawomir.messner@staff.uni-marburg.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

  
    
  
  <div text="#000000" bgcolor="#ffffff">
    Hi,<br>
    we have/had the same &quot;issue&quot;(luckily we could change to server-side
    formatting). If you call the function below with
    &quot;exportToFormat(mylayer,&#39;kml&#39;)&quot; you will get a download
    dialogue(tested with FF 3.6-4.0), !!but!! the write-function of
    OpenLayers.Format.KML(I think with json it&#39;s the same) is not
    perfect because style info is missing, if you&#39;re will enhance it.<br>
    <pre style="font-family: consolas;">exportToFormat: <span style="color: blue;">function</span> (layer, format) {
          <span style="color: blue;">if</span> (layer <span style="color: blue;">instanceof</span> OpenLayers.Layer.Vector &amp;&amp; layer.features.length == 0) {
              <span style="color: blue;">return</span>;
          }
          <span style="color: blue;">var</span> formatText = <span style="color: blue;">null</span>;
          <span style="color: blue;">var</span> mimeType = <span style="color: blue;">null</span>;
          <span style="color: blue;">if</span> (format == <span style="color: maroon;">&#39;svg&#39;</span>) {
              mimeType = <span style="color: maroon;">&quot;image/svg+xml&quot;</span>;
              formatText = document.getElementById(<a href="http://layer.id" target="_blank">layer.id</a>).innerHTML;
          } <span style="color: blue;">else</span> <span style="color: blue;">if</span> (format == <span style="color: maroon;">&#39;kml&#39;</span>) {
              mimeType = <span style="color: maroon;">&quot;application/vnd.google-earth.kml+xml&quot;</span>;
              <span style="color: blue;">var</span> format = <span style="color: blue;">new</span> OpenLayers.Format.KML(
              { extractAttributes: <span style="color: blue;">true</span>,
                  extractTracks: <span style="color: blue;">true</span>,
                  internalProjection : <span style="color: blue;">new</span> OpenLayers.Projection(<span style="color: maroon;">&quot;EPSG:900913&quot;</span>),
                  externalProjection : <span style="color: blue;">new</span> OpenLayers.Projection(<span style="color: maroon;">&quot;EPSG:4326&quot;</span>)
              }
              );
              <span style="color: blue;">var</span> features = <span style="color: blue;">new</span> Array();
              <span style="color: blue;">var</span> operation = <span style="color: blue;">new</span> OpenLayers.Operation.CopyFeatureToLayer();
              <span style="color: blue;">for</span> (<span style="color: blue;">var</span> i = 0; i &lt; layer.features.length; i++) {
                  <span style="color: blue;">var</span> newfeature = <span style="color: blue;">new</span> OpenLayers.Feature.Vector(layer.features[i].geometry.clone());
                  newfeature.style = layer.features[i].style || layer.styleMap.createSymbolizer(layer.features[i], layer.features[i].renderIntent || <span style="color: maroon;">&#39;default&#39;</span>);
                  newfeature.attributes = operation.clone(layer.features[i].attributes);
                  features.push(newfeature);
              }
              formatText = format.write(features);
          }
          <span style="color: blue;">if</span> (formatText != <span style="color: blue;">null</span>) {
              open(<span style="color: maroon;">&quot;data:&quot;</span> + mimeType + <span style="color: maroon;">&quot;,&quot;</span> + encodeURIComponent(<span style="color: maroon;">&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt; &quot;</span> + formatText));
          }
      },</pre>
    <br>
    <br>
    Am 21.01.2011 15:17, schrieb David Zwarg:
    <div><div></div><div class="h5"><blockquote type="cite">Hello Mohammed,<br>
      <br>
      Look at the OpenLayers.Format classes.<br>
      <br>
      Here&#39;s a link to the geojson format example: <a href="http://dev.openlayers.org/apidocs/files/OpenLayers/Format/GeoJSON-js.html" target="_blank">http://dev.openlayers.org/apidocs/files/OpenLayers/Format/GeoJSON-js.html</a><br>

      <br>
      You will probably do something like:<br>
      <br>
      <span style="font-family: courier new,monospace; color: rgb(0, 0, 153);">var format = new OpenLayers.Format.GeoJSON();</span><br style="font-family: courier new,monospace; color: rgb(0, 0, 153);">
      <br style="font-family: courier new,monospace; color: rgb(0, 0, 153);">
      <span style="font-family: courier new,monospace; color: rgb(0, 0, 153);">// given that &#39;layer&#39; is a vector layer attached to the
        map with some features:</span><br style="font-family: courier new,monospace; color: rgb(0, 0, 153);">
      <span style="font-family: courier new,monospace; color: rgb(0, 0, 153);">var jsonstring = format.write( layer.features );</span><br style="font-family: courier new,monospace; color: rgb(0, 0, 153);">
      <br style="font-family: courier new,monospace; color: rgb(0, 0, 153);">
      <span style="font-family: courier new,monospace; color: rgb(0, 0, 153);">// given that &#39;txtarea&#39; is an HTML textarea element
        somewhere in your page to display the geojson:</span><br style="font-family: courier new,monospace; color: rgb(0, 0, 153);">
      <span style="font-family: courier new,monospace; color: rgb(0, 0, 153);">txtarea.value = jsonstring;</span><br>
      <br>
      There&#39;s no way to save the file directly via openlayers (opening a
      &quot;Save File...&quot; dialog), you have to do some copy &amp; pasting
      from the browser.<br>
      <br>
      -z<br>
      <br>
      <div class="gmail_quote">On Fri, Jan 21, 2011 at 8:51 AM, Mohammed
        Rashad <span dir="ltr">&lt;<a href="mailto:mohammedrashadkm@gmail.com" target="_blank">mohammedrashadkm@gmail.com</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
          How can I save a OpenLayers.Layer.Vector to a gml, geojson or
          any openlayer supported formats without using
          <div> WFS or WFS- T( without geoserver,postgis);</div>
          <div><br>
          </div>
          <div>Is it possible?<br clear="all">
            <br>
            -- <br>
            Rashad<br>
          </div>
          <br>
          _______________________________________________<br>
          Dev mailing list<br>
          <a href="mailto:Dev@lists.osgeo.org" target="_blank">Dev@lists.osgeo.org</a><br>
          <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-dev</a><br>
          <br>
        </blockquote>
      </div>
      <br>
      <pre><fieldset></fieldset>
_______________________________________________
Dev mailing list
<a href="mailto:Dev@lists.osgeo.org" target="_blank">Dev@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-dev</a>
</pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
Dev mailing list<br>
<a href="mailto:Dev@lists.osgeo.org">Dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-dev</a><br>
<br></blockquote></div><br>