Hello,

I'm currently trying to play with the KML Format and I have in the data I'm 
using some Multipolygon objects.
I know that its not completely supported yet and that I should submit a patch 
with a real test case but I'm very short on time on my projet and I've done a 
few ugly hacks that make things work with Firefox (but not IE yet).

So, I'm just posting this in case someone have more time than me to look at 
this subject.

For the export, the "buildGeometry.collection" method in the KML format is not 
working because "this" is refering to the "buildGeometry" object instead of the 
"KML" object.
I've added an ugly "var obj = new OpenLayers.Format.KML();" to make things 
work, but it's probably not the best way to do.


        /**
         * Method: buildGeometry.collection
         * Given an OpenLayers geometry collection, create a KML MultiGeometry.
         *
         * Parameters:
         * geometry - {<OpenLayers.Geometry.Collection>} A geometry collection.
         *
         * Returns:
         * {DOMElement} A KML MultiGeometry node.
         */
        collection: function(geometry) {
            var obj = new OpenLayers.Format.KML();
            var kml = obj.createElementNS(obj.kmlns, "MultiGeometry");
            var child;
            for(var i=0; i<geometry.components.length; ++i) {
                child = obj.buildGeometryNode.apply(obj,
                                                     [geometry.components[i]]);
                if(child) {
                    kml.appendChild(child);
                }
            }
            return kml;
        }
    },

For the import, the parser doesn't seems to support the presence of the "id" 
attribute in the Placemark tag, i've commented the following line of the 
"createPlacemarkXML" method :
placemarkNode.setAttribute("id", feature.fid);

And last thing, the "MultiGeometry" node is not found by the parser, i've put 
the node names in lowercase in the "parseFeature" method :
var order = ["multigeometry", "polygon", "linestring", "point"];
        
I'll try to correct this for Internet Explorer too and to give more 
informations ...

Best Regards,

Benoit Pesty.
_________________________________________________________________
Windows Live Hotmail and Microsoft Office Outlook – together at last.  Get it 
now.
http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033
_______________________________________________
Dev mailing list
[email protected]
http://openlayers.org/mailman/listinfo/dev

Reply via email to