Changeset 5794
- Timestamp:
- 01/17/08 01:55:12 (11 months ago)
- Files:
-
- sandbox/rdewit/kml/lib/OpenLayers/Format/KML.js (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/rdewit/kml/lib/OpenLayers/Format/KML.js
r5792 r5794 66 66 /** 67 67 * Property: gmlns 68 * {String} GML Namespace to use -- defaults to the namespace "*"68 * {String} GML Namespace to use -- defaults to the namespace this.internalns 69 69 * 70 70 */ … … 86 86 87 87 /** 88 * Property: loadedKML88 * Property: fetched 89 89 * {Object} Storage of KML URLs that have been fetched before 90 90 * in order to prevent reloading them. 91 91 */ 92 loadedKML: {},92 fetched: {}, 93 93 94 94 /** … … 101 101 */ 102 102 initialize: function(options) { 103 OpenLayers.Format.GML.prototype.initialize.apply(this, [options]); 104 103 105 // compile regular expressions once instead of every time they are used 104 106 this.regExes = { … … 106 108 removeSpace: (/\s*/g), 107 109 splitSpace: (/\s+/), 108 trimComma: (/\s*,\s*/g) 110 trimComma: (/\s*,\s*/g), 111 kmlColor: (/(\w{2})(\w{2})(\w{2})(\w{2})/), 112 kmlIconPalette: (/root:\/\/icons\/palette-(\d+)(\.\w+)/), 113 straightBracket: (/\$\[(.*?)\]/g) 109 114 }; 110 OpenLayers.Format.GML.prototype.initialize.apply(this, [options]);111 115 112 116 }, … … 122 126 * {Array(<OpenLayers.Feature.Vector>)} List of features. 123 127 */ 124 read: function(data) { 125 128 read: function(data, recursion) { 126 129 if(typeof data == "string") { 127 130 data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); … … 133 136 // Should not be in Format/KML.js. 134 137 var serviceException = this.getElementsByTagNameNS(data, 135 "*",138 this.internalns, 136 139 "ServiceException")[0]; 137 140 if (serviceException) { … … 141 144 message += code + "\n"; 142 145 } 143 message += OpenLayers.Util.getXmlNodeValue(serviceException).replace(this.regExes.trimSpace, ""); 146 message += OpenLayers.Util.getXmlNodeValue( 147 serviceException).replace(this.regExes.trimSpace, ""); 144 148 alert(message); 145 149 return false; … … 148 152 149 153 var urlNodes = this.getElementsByTagNameNS(data, 150 '*',154 this.internalns, 151 155 "Url"); 152 156 var numurls = urlNodes.length; … … 154 158 for(var i=0; i<numurls; i++) { 155 159 var hrefNode = this.getElementsByTagNameNS(urlNodes[i], 156 "*",160 this.internalns, 157 161 "href")[0]; 158 162 //console.info(url); … … 160 164 var href = OpenLayers.Util.getXmlNodeValue(hrefNode); 161 165 162 if (this. loadedKML[href]) {166 if (this.fetched[href]) { 163 167 continue; 164 168 } 165 169 166 170 //console.info(href); 167 if (OpenLayers.ProxyHost && OpenLayers.String.startsWith(href, "http")) { 171 if (OpenLayers.ProxyHost 172 && OpenLayers.String.startsWith(href, "http")) { 168 173 href = OpenLayers.ProxyHost + escape(href); 169 174 } 170 var request = new OpenLayers.Ajax.Request(href, {method: 'get', asynchronous: false }); 171 this.loadedKML[href] = true; // prevent reloading the same urls 175 var request = new OpenLayers.Ajax.Request(href, 176 {method: 'get', asynchronous: false }); 177 this.fetched[href] = true; // prevent reloading the same urls 172 178 if (request && request.transport) { 173 this.read(request.transport.responseText );179 this.read(request.transport.responseText, true); 174 180 } 175 181 } … … 177 183 178 184 var linkNodes = this.getElementsByTagNameNS(data, 179 '*',185 this.internalns, 180 186 "Link"); 181 187 var numlinks = linkNodes.length; … … 183 189 for(var i=0; i<numlinks; i++) { 184 190 var hrefNode = this.getElementsByTagNameNS(linkNodes[i], 185 "*",191 this.internalns, 186 192 "href")[0]; 187 193 //console.info(link); … … 189 195 var href = OpenLayers.Util.getXmlNodeValue(hrefNode); 190 196 191 if (this. loadedKML[href]) {197 if (this.fetched[href]) { 192 198 continue; 193 199 } 194 200 195 if (OpenLayers.ProxyHost && OpenLayers.String.startsWith(href, "http")) { 201 if (OpenLayers.ProxyHost 202 && OpenLayers.String.startsWith(href, "http")) { 196 203 href = OpenLayers.ProxyHost + escape(href); 197 204 } 198 var request = new OpenLayers.Ajax.Request(href, {method: 'get', asynchronous: false }); 199 this.loadedKML[href] = true; // prevent reloading the same urls 205 var request = new OpenLayers.Ajax.Request(href, 206 {method: 'get', asynchronous: false }); 207 this.fetched[href] = true; // prevent reloading the same urls 200 208 if (request && request.transport) { 201 this.read(request.transport.responseText );209 this.read(request.transport.responseText, true); 202 210 } 203 211 } … … 206 214 // 207 215 // Parse internal Style information 208 this. readStyles(data);216 this.parseStyles(data); 209 217 210 218 … … 221 229 //var feature = this.parseFeature(featureNodes[i]); 222 230 var featureNode = featureNodes[i]; 223 var feature = OpenLayers.Format.GML.prototype.parseFeature.apply(this,[featureNode]) ; 231 var feature = OpenLayers.Format.GML.prototype.parseFeature.apply( 232 this,[featureNode]) ; 224 233 225 234 //console.info(feature); 226 235 if(feature) { 227 236 // give feature default style 228 feature.style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style["default"]); 237 feature.style = OpenLayers.Util.extend({}, 238 OpenLayers.Feature.Vector.style["default"]); 229 239 230 240 if (feature.attributes.styleUrl) { 231 //console.info(styleUrl, feature.style, this.getStyle(styleUrl));232 241 var newStyle = this.getStyle(feature.attributes.styleUrl); 233 242 234 243 if (newStyle) { 235 feature.style = OpenLayers.Util.extend(feature.style, newStyle ); 244 feature.style = OpenLayers.Util.extend(feature.style, 245 newStyle); 236 246 } 237 247 //console.info(feature.style); … … 241 251 // processed as well: add a styleUrl attribute to the feature. 242 252 var styleNode = this.getElementsByTagNameNS(featureNode, 243 '*',253 this.internalns, 244 254 "Style")[0]; 245 255 if (styleNode) { … … 247 257 //console.info(style.name, style); 248 258 if (style) { 249 feature.style = OpenLayers.Util.extend(feature.style, style ); 259 feature.style = OpenLayers.Util.extend(feature.style, 260 style); 250 261 } 251 262 } … … 264 275 265 276 // Reverse drawing order of features (this seems to be standard in KML) 266 if ( this.reverseFeatures) {277 if (!recursion && this.reverseFeatures) { 267 278 this.features.reverse(); 268 279 } … … 281 292 282 293 getStyle: function(styleUrl) { 283 // Fetch remote Style URLs 284 var baseUrl = OpenLayers.Util.removeTail(styleUrl); 285 //console.info(baseUrl, styleUrl); 286 287 if (!this.styles[styleUrl] && !OpenLayers.String.startsWith(styleUrl, "#") && !this.loadedKML[baseUrl] ) { 288 294 295 // Fetch remote Style URLs (if not fetched before) 296 if (!this.styles[styleUrl] 297 && !OpenLayers.String.startsWith(styleUrl, "#") 298 && !this.fetched[baseUrl] ) { 299 300 var baseUrl = OpenLayers.Util.removeTail(styleUrl); 289 301 var href = baseUrl; 302 290 303 if (OpenLayers.String.startsWith(styleUrl, "http")) { 291 304 href = OpenLayers.ProxyHost + escape(baseUrl); 292 305 } 293 306 294 var request = new OpenLayers.Ajax.Request(href, {method: 'get', asynchronous: false }); 307 var request = new OpenLayers.Ajax.Request(href, 308 {method: 'get', asynchronous: false }); 295 309 if (request && request.transport) { 296 this. loadedKML[baseUrl] = true; // prevent loading more than once310 this.fetched[baseUrl] = true; // prevent loading more than once 297 311 var data = request.transport.responseText; 298 312 if(typeof data == "string") { 299 data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); 313 data = OpenLayers.Format.XML.prototype.read.apply(this, 314 [data]); 300 315 } 301 316 if (data) { 302 this.readStyles(data, baseUrl); 303 } 304 } 305 306 } 307 308 // some KML files don't have a # for internal styles. add one 309 //if (styleUrl.substring(0,4) != "http" && styleUrl.substring(0,1) != "#") { 310 //styleUrl = "#" + styleUrl; 311 //} 312 317 this.parseStyles(data, baseUrl); 318 } 319 } 320 321 } 322 323 // return requested style 313 324 var style = this.styles[styleUrl]; 314 //console.info(style);315 316 325 return style; 317 326 }, 318 327 319 328 320 readStyles: function(data, baseUrl) { 329 330 parseStyles: function(data, baseUrl) { 321 331 if (!data) { 322 332 return null; 323 333 } 324 334 325 //this.counter++; 326 //console.info("readStyles", this.counter, baseUrl); 327 328 if (this.counter > 20 ) { return null} 335 if (!baseUrl) { 336 baseUrl = ""; 337 } 329 338 330 339 // Parse Styles 331 340 var styleNodes = this.getElementsByTagNameNS(data, 332 '*',341 this.internalns, 333 342 "Style"); 334 343 … … 350 359 // To do the select or "highlight" bit, we'd need to change lots more 351 360 var styleMapNodes = this.getElementsByTagNameNS(data, 352 '*',361 this.internalns, 353 362 "StyleMap"); 354 363 … … 357 366 for(var i=0; i<numNodes; i++) { 358 367 var node = styleMapNodes[i]; 359 var pairs = this.getElementsByTagNameNS(node, "*", "Pair");360 //console.info(pairs);368 var pairs = this.getElementsByTagNameNS(node, this.internalns, 369 "Pair"); 361 370 362 371 var id = node.getAttribute("id"); … … 364 373 pair = pairs[j]; 365 374 366 // Use the shortcut in the SLD format to quickly retrieve the value of a node 367 // Maybe it's good to have a method in Util to do this 368 key = OpenLayers.Format.SLD.prototype.parseProperty(pair, "*", "key"); 369 styleUrl = OpenLayers.Format.SLD.prototype.parseProperty(pair, "*", "styleUrl"); 375 // Use the shortcut in the SLD format to quickly retrieve the 376 // value of a node. Maybe it's good to have a method in Util 377 // to do this 378 key = OpenLayers.Format.SLD.prototype.parseProperty(pair, 379 this.internalns, "key"); 380 styleUrl = OpenLayers.Format.SLD.prototype.parseProperty(pair, 381 this.internalns, "styleUrl"); 370 382 371 383 if (key == "normal") { 372 styles[(baseUrl || "") + "#" + id] = styles[(baseUrl || "") + styleUrl]; 384 styles[(baseUrl || "") + "#" + id] = styles[(baseUrl || "") 385 + styleUrl]; 373 386 } 374 387 … … 382 395 //console.info("before", this.styles); 383 396 OpenLayers.Util.extend(this.styles, styles); 397 384 398 //console.info("after", this.styles); 385 399 }, 386 400 387 401 parseStyle: function(node) { 388 389 var styleObject = {};390 391 /**392 * Constant: OpenLayers.Feature.Vector.style393 * OpenLayers features can have a number of style attributes. The 'default'394 * style will typically be used if no other style is specified.395 *396 * Default style properties:397 *398 * - fillColor: "#ee9900",399 * - fillOpacity: 0.4,400 * - hoverFillColor: "white",401 * - hoverFillOpacity: 0.8,402 * - strokeColor: "#ee9900",403 * - strokeOpacity: 1,404 * - strokeWidth: 1,405 * - strokeLinecap: "round",406 * - hoverStrokeColor: "red",407 * - hoverStrokeOpacity: 1,408 * - hoverStrokeWidth: 0.2,409 * - pointRadius: 6,410 * - hoverPointRadius: 1,411 * - hoverPointUnit: "%",412 * - pointerEvents: "visiblePainted"413 *414 * Other style properties that have no default values:415 *416 * - externalGraphic,417 * - graphicWidth,418 * - graphicHeight,419 * - graphicOpacity420 * - graphicXOffset421 * - graphicYOffset422 */423 424 402 var style = {}; 425 403 … … 432 410 styleTypeNode = this.getElementsByTagNameNS(node, 433 411 this.internalns, type)[0]; 434 if(styleTypeNode) { 435 // only deal with first geometry of this type 436 //console.info(styleTypeNode); 437 switch (type.toLowerCase()) { 438 case "linestyle": 439 colorNode = this.getElementsByTagNameNS(styleTypeNode, 440 "*", 441 "color")[0]; 442 if (colorNode) { 443 var alpha = (OpenLayers.Util.getXmlNodeValue(colorNode)).substring(0, 2); 444 style["strokeOpacity"] = parseInt(alpha, 16) / 255; 445 446 var b = (OpenLayers.Util.getXmlNodeValue(colorNode)).substring(2, 4); 447 var g = (OpenLayers.Util.getXmlNodeValue(colorNode)).substring(4, 6); 448 var r = (OpenLayers.Util.getXmlNodeValue(colorNode)).substring(6, 8); 449 style["strokeColor"] = "#" + r + g + b; 412 if(!styleTypeNode) { 413 continue; 414 } 415 416 // only deal with first geometry of this type 417 //console.info(styleTypeNode); 418 switch (type.toLowerCase()) { 419 case "linestyle": 420 colorNode = this.getElementsByTagNameNS(styleTypeNode, 421 this.internalns, 422 "color")[0]; 423 if (colorNode) { 424 var colorNodeValue = OpenLayers.Util.getXmlNodeValue( 425 colorNode); 426 var matches = colorNodeValue.match( 427 this.regExes.kmlColor); 428 429 // transparency 430 var alpha = matches[1]; 431 style["strokeOpacity"] = parseInt(alpha, 16) / 255; 432 433 // rgb colors (google uses bgr) 434 var b = matches[2]; 435 var g = matches[3]; 436 var r = matches[4]; 437 style["strokeColor"] = "#" + r + g + b; 438 } 439 440 widthNode = this.getElementsByTagNameNS(styleTypeNode, 441 this.internalns, 442 "width")[0]; 443 if (widthNode) { 444 style["strokeWidth"] = OpenLayers.Util.getXmlNodeValue( 445 widthNode); 446 } 447 448 case "polystyle": 449 colorNode = this.getElementsByTagNameNS(styleTypeNode, 450 this.internalns, 451 "color")[0]; 452 if (colorNode) { 453 var colorNodeValue = OpenLayers.Util.getXmlNodeValue( 454 colorNode); 455 var matches = colorNodeValue.match( 456 this.regExes.kmlColor); 457 458 console.info(matches); 459 // transparency 460 var alpha = matches[1]; 461 style["fillOpacity"] = parseInt(alpha, 16) / 255; 462 463 // rgb colors (google uses bgr) 464 var b = matches[2]; 465 var g = matches[3]; 466 var r = matches[4]; 467 style["fillColor"] = "#" + r + g + b; 468 } 469 470 break; 471 case "iconstyle": 472 iconNode = this.getElementsByTagNameNS(styleTypeNode, 473 this.internalns, 474 "Icon")[0]; 475 476 // set default width and height of icon 477 style["graphicWidth"] = 32; 478 style["graphicHeight"] = 32; 479 480 if (iconNode) { 481 hrefNode = this.getElementsByTagNameNS(iconNode, 482 this.internalns, 483 "href")[0]; 484 if (hrefNode) { 485 href = OpenLayers.Util.getXmlNodeValue(hrefNode); 486 487 // support for internal icons 488 // (/root://icons/palette-x.png) 489 // x and y tell the position on the palette: 490 // - in pixels 491 // - starting from the left bottom 492 // We need to translate that to a position in the 493 // list and request the appropriate icon from the 494 // google maps website 495 matches = href.match(this.regExes.kmlIconPalette); 496 if (matches) { 497 var palette = matches[1]; 498 var file_extension = matches[2]; 499 500 var xNode = this.getElementsByTagNameNS(iconNode, 501 this.internalns, 502 "x")[0]; 503 var x = OpenLayers.Util.getXmlNodeValue(xNode); 504 505 var yNode = this.getElementsByTagNameNS(iconNode, 506 this.internalns, 507 "y")[0]; 508 var y = OpenLayers.Util.getXmlNodeValue(yNode); 509 510 var posX = x ? x/32 : 0; 511 var posY = y ? (7 - y/32) : 7; 512 513 var pos = posY * 8 + posX; 514 href = "http://maps.google.com/mapfiles/kml/pal" 515 + palette + "/icon" + pos + file_extension; 516 //console.info(x,y, pos, href); 517 } 518 519 520 var wNode = this.getElementsByTagNameNS(iconNode, 521 this.internalns, 522 "w")[0]; 523 w = OpenLayers.Util.getXmlNodeValue(wNode); 524 525 var hNode = this.getElementsByTagNameNS(iconNode, 526 this.internalns, 527 "h")[0]; 528 h = OpenLayers.Util.getXmlNodeValue(hNode); 529 530 if (w) { 531 style["graphicWidth"] = parseInt(w); 532 } 533 534 if (h) { 535 style["graphicHeight"] = parseInt(h); 536 } 537 538 style["graphicOpacity"] = 1; 539 style["externalGraphic"] = href; 450 540 } 451 452 widthNode = this.getElementsByTagNameNS(styleTypeNode, 453 "*", 454 "width")[0]; 455 if (widthNode) { 456 style["strokeWidth"] = OpenLayers.Util.getXmlNodeValue(widthNode); 541 542 } 543 544 545 // hotSpots define the offset for an Icon 546 hotSpotNode = this.getElementsByTagNameNS(styleTypeNode, 547 this.internalns, 548 "hotSpot")[0]; 549 if (false && hotSpotNode) { 550 var x = hotSpotNode.getAttribute("x"); 551 var y = hotSpotNode.getAttribute("y"); 552 553 var xUnits = hotSpotNode.getAttribute("xunits"); 554 if (xUnits == "pixels") { 555 style["graphicXOffset"] = parseInt(x); 457 556 } 458 459 case "polystyle": 460 colorNode = this.getElementsByTagNameNS(styleTypeNode, 461 "*", 462 "color")[0]; 463 if (colorNode) { 464 var alpha = (OpenLayers.Util.getXmlNodeValue(colorNode)).substring(0, 2); 465 style["fillOpacity"] = parseInt(alpha, 16) / 255; 466 467 var b = (OpenLayers.Util.getXmlNodeValue(colorNode)).substring(2, 4); 468 var g = (OpenLayers.Util.getXmlNodeValue(colorNode)).substring(4, 6); 469 var r = (OpenLayers.Util.getXmlNodeValue(colorNode)).substring(6, 8); 470 style["fillColor"] = "#" + r + g + b; 557 else if (xUnits == "insetPixels") { 558 style["graphicXOffset"] = style["graphicWidth"] 559 - parseInt(x); 471 560 } 472 473 break; 474 case "iconstyle": 475 iconNode = this.getElementsByTagNameNS(styleTypeNode, 476 "*", 477 "Icon")[0]; 478 479 // set default width and height of icon 480 style["graphicWidth"] = 32; 481 style["graphicHeight"] = 32; 482 483 if (iconNode) { 484 hrefNode = this.getElementsByTagNameNS(iconNode, 485 "*", 486 "href")[0]; 487 if (hrefNode) { 488 href = OpenLayers.Util.getXmlNodeValue(hrefNode); 489 490 // support for internal icons (/root://icons/palette-x.png) 491 // x and y tell the position on the palette: 492 // - in pixels 493 // - starting from the left bottom 494 // We need to translate that to a position in the list 495 // and request the appropriate icon from the 496 // google maps website 497 matches = href.match(/root:\/\/icons\/palette-(\d+)(\.\w+)/); 498 if (matches) { 499 var palette = matches[1]; 500 var file_extension = matches[2]; 501 502 var xNode = this.getElementsByTagNameNS(iconNode, 503 "*", 504 "x")[0]; 505 var x = OpenLayers.Util.getXmlNodeValue(xNode); 506 507 var yNode = this.getElementsByTagNameNS(iconNode, 508 "*", 509 "y")[0]; 510 var y = OpenLayers.Util.getXmlNodeValue(yNode); 511 512 var posX = x ? x/32 : 0; 513 var posY = y ? (7 - y/32) : 7; 514 515 var pos = posY * 8 + posX; 516 href = "http://maps.google.com/mapfiles/kml/pal" + palette + "/icon" + pos + file_extension; 517 //console.info(x,y, pos, href); 518 } 519 520 521 var wNode = this.getElementsByTagNameNS(iconNode, 522 "*", 523 "w")[0]; 524 w = OpenLayers.Util.getXmlNodeValue(wNode); 525 526 var hNode = this.getElementsByTagNameNS(iconNode, 527 "*", 528 "h")[0]; 529 h = OpenLayers.Util.getXmlNodeValue(hNode); 530 531 if (w) { 532 style["graphicWidth"] = parseInt(w); 533 } 534 535 if (h) { 536 style["graphicHeight"] = parseInt(h); 537 } 538 539 style["graphicOpacity"] = 1; 540 style["externalGraphic"] = href; 541 } 542 561 else if (xUnits == "fraction") { 562 style["graphicXOffset"] = style["graphicWidth"] 563 * parseFloat(x); 543 564 } 544 565 545 546 // hotSpots define the offset for an Icon 547 hotSpotNode = this.getElementsByTagNameNS(styleTypeNode, 548 "*", 549 "hotSpot")[0]; 550 if (false && hotSpotNode) { 551 var x = hotSpotNode.getAttribute("x"); 552 var y = hotSpotNode.getAttribute("y"); 553 554 var xUnits = hotSpotNode.getAttribute("xunits"); 555 if (xUnits == "pixels") { 556 style["graphicXOffset"] = parseInt(x); 557 } 558 else if (xUnits == "insetPixels") { 559 style["graphicXOffset"] = style["graphicWidth"] - parseInt(x); 560 } 561 else if (xUnits == "fraction") { 562 style["graphicXOffset"] = style["graphicWidth"] * parseFloat(x); 563 } 564 565 var yUnits = hotSpotNode.getAttribute("yunits"); 566 if (yUnits == "pixels") { 567 style["graphicYOffset"] = parseInt(y); 568 } 569 else if (yUnits == "insetPixels") { 570 style["graphicYOffset"] = style["graphicHeight"] - parseInt(y); 571 } 572 else if (yUnits == "fraction") { 573 style["graphicYOffset"] = style["graphicHeight"] * parseFloat(y); 574 } 575 //console.info(x, xUnits, y, yUnits, style["graphicXOffset"], style["graphicYOffset"]); 566 var yUnits = hotSpotNode.getAttribute("yunits"); 567 if (yUnits == "pixels") { 568 style["graphicYOffset"] = parseInt(y); 576 569 } 577 578 579 580 break; 581 case "balloonstyle": 582 balloonStyle = OpenLayers.Util.getXmlNodeValue(styleTypeNode); 583 if (balloonStyle) { 584 balloonStyle = balloonStyle.replace(/\$\[(.*?)\]/g, "${$1}"); 585 style["balloonStyle"] = balloonStyle; 586 //console.info(balloonStyle); 570 else if (yUnits == "insetPixels") { 571 style["graphicYOffset"] = style["graphicHeight"] 572 - parseInt(y); 587 573 } 588 break; 589 default: 590 } 591 } 592 } 574 else if (yUnits == "fraction") { 575 style["graphicYOffset"] = style["graphicHeight"] 576 * parseFloat(y); 577 } 578 //console.info(x, xUnits, y, yUnits, style["graphicXOffset"], 579 // style["graphicYOffset"]); 580 } 581 break; 582 case "balloonstyle": 583 balloonStyle = OpenLayers.Util.getXmlNodeValue(styleTypeNode); 584 if (balloonStyle) { 585 style["balloonStyle"] = balloonStyle.replace( 586 straightBracket, "${$1}"); 587 //console.info(balloonStyle); 588 } 589 break; 590 default: 591 } 592 } 593 594 595 // Some polygons have no line color, so we use that 593 596 if (!style["strokeColor"]) { 594 597 style["strokeColor"] = style["fillColor"]; 595 598 } 596 599 597 var id = node.getAttribute("id"); 598 if (!id) { 599 id = "generated_" + Math.floor(Math.random()*100000); 600 } 601 style["name"] = id; 602 //var styleObject = new OpenLayers.Style(style, options); 603 //console.debug(style); 600 // Give the style a name 601 style["name"] = node.getAttribute("id"); 602 604 603 return style; 605 604 },
