Ticket #1954 (new feature)

Opened 4 years ago

Last modified 4 years ago

KML balloonStyle parsing is broken

Reported by: crschmidt Owned by: tschaub
Priority: minor Milestone: Future
Component: Format.KML Version: 2.7
Keywords: Cc:
State:

Description

The KML balloonStyle parsing is buggy:

  • It uses Util.getXMLNodeValue (ew.)
  • It assumes that the text will be directly in the balloonStyle element, not in balloonStyle.text, where it actually is.

Change History

Changed 4 years ago by crschmidt

A solution to #2, along with some other improvements for working with advanced KML balloonStyles.

                case "balloonstyle":
                    var balloonStyle = OpenLayers.Util.getXmlNodeValue(
                                            styleTypeNode.getElementsByTagName("text")[0]);
                    if (balloonStyle) {
                        var balloon = balloonStyle.replace(
                                       this.regExes.straightBracket,
                            function(str, match) {
                                var out = match;
                                var nothing = false;
                                if (match == "name" || match == "description" || match == "Snippet") {
                                } else if (match == "address" || match == "geDirections" || match == "id") {
                                    nothing = true;
                                } else if (match.contains("/displayName")) {
                                    out = match.replace("/displayName", ".displayName");
                                } else {
                                    out = match + ".value";
                                }

                                var ret = nothing ? "" : "${"+out+"}";
                                return ret;
                            }
                        );
                        style['balloonStyle'] = balloon;
                    }
                    break;
Note: See TracTickets for help on using tickets.