[OpenLayers-Dev] Multipolygon and KML

Tim Schaub tschaub at openplans.org
Fri Nov 9 13:48:08 EST 2007


Benoit PESTY wrote:
> Hello,
> I'm currently trying to play with the KML Format and I have in the data 
> I'm using some Multipolygon objects.

Thanks for trying this out.

> 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).

At this point, I'm still not completely clear on what issue you may be 
referring to.  Even if you can't create a ticket, fix the issue, make 
tests, and create a patch, it would help to clearly spell out the 
problem.  For example, if I were reading your mind, I might describe the 
problem as this:

"The OpenLayers.Format.KML fails to write an 

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

Nobody has any more time than you do :)

> 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.

Ok, I think I'm following.  Though when I see all that code below, I go 
a bit crosseyed and stop reading.

However, if the problem you're referring to is the one I guessed above, 
please see http://trac.openlayers.org/ticket/1132.

And let me know if the attach patch fixes your problem.  If you are 
having more issues with the KML format, please write back.

And a very short email with a concise description of the issue - without 
a lot of inline code and long narrative - is a bit easier to start with 
(for me at least).  Unless attached as a patch, I typically disregard 
code modifications that are described inline (in an email).


>         /**
>          * 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> 
> !DSPAM:4033,4731f16a268354901796417!
> ------------------------------------------------------------------------
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
> !DSPAM:4033,4731f16a268354901796417!

More information about the Dev mailing list