Hello everybody,
 
im using OpenLayers 2.12 and want to export vector layers (some routes served by geoserver) as kml and gpx files.
Now i found two different api versions:
http://dev.openlayers.org/docs/files/OpenLayers/Format/KML-js.html
which has a lot more functions then
http://dev.openlayers.org/releases/OpenLayers-2.12/doc/apidocs/files/OpenLayers/Format/KML-js.html
which has only the write function to export.
 
I wonder which one works, or with which OL version.
Using the first one get the following errors (complete code below):
Uncaught TypeError: Cannot read property 'collection' of undefined
when i try
console.log(format.buildGeometry.multilinestring(record.data.geometry));
or
Uncaught TypeError: Object #<Object> has no method 'createElementNS'
when i try to export a single linestring
console.log(format.buildGeometry.linestring(record.data.geometry.components[0]));
 
Is there something i'm missing or doing wrong? Below is my code snippet.
 
I think the MultiLineString Object should be ok, as it looks like this
constructor {raw: Object, modified: Object, data: Object, hasListeners: HasListeners, events: Object}
  1. data: Object
    1. geometry: C
      1. bounds: OpenLayers.Bounds.OpenLayers.Class.initialize
      2. components: Array[334]
        1. [0 … 99]
        2. [100 … 199]
        3. [200 … 299]
        4. [300 … 333]
        5. length: 334
        6. __proto__: Array[0]
      3. id: "OpenLayers.Geometry.MultiLineString_2691"
 
This is my code snippet:
onDownloadRouteClick: function(grid, view, rowIndex, colIndex){
        var record = grid.getStore().getAt(rowIndex);               // the MultilineString Object seen above
            var format = new OpenLayers.Format.KML({
                internalProjection: this.getMappanel().map.baseLayer.projection,
                externalProjection: new OpenLayers.Projection("EPSG:4326")
            });
        console.log(format.buildGeometry.multilinestring(record.data.geometry));
 
 
Finally (after solving this problem ;) i'm facing the next problem how to get the user friendly download popup. If somebody as experience/ or an example how i can get a downloadable file from the string i would be very thankful :)
 
Thanks
Christian
 
 
_______________________________________________
Users mailing list
us...@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to