Changeset 5792
- Timestamp:
- 01/16/08 21:19:30 (11 months ago)
- Files:
-
- sandbox/rdewit/kml/examples/kml_wmsc_ows5.html (modified) (6 diffs)
- sandbox/rdewit/kml/examples/proxy.cgi (modified) (1 diff)
- sandbox/rdewit/kml/lib/OpenLayers/Format/KML.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/rdewit/kml/examples/kml_wmsc_ows5.html
r5704 r5792 108 108 var loadingLayers = 0; 109 109 110 //OpenLayers.ProxyHost = "proxy.php?url=";111 110 //OpenLayers.ProxyHost = "/mapbuilder/MapbuilderProxy.jsp?url="; 112 111 OpenLayers.ProxyHost = "proxy.cgi?url="; 112 //OpenLayers.ProxyHost = "proxy.php?url="; 113 113 114 114 var wmscURL = "http://geo.openplans.org:8080/geoserver/wms"; … … 201 201 function onFeatureSelect(feature) { 202 202 selectedFeature = feature; 203 204 203 var content; 205 204 if (feature.style.balloonStyle) { … … 307 306 var url = element.value; 308 307 increaseLoadingLayers(); 308 //url = url.replace(/\+/, "%2B"); // escape the '+' character 309 309 OpenLayers.loadURL(url, null, null, loadUrlSuccess, loadUrlFailure); 310 310 } … … 504 504 <option disabled="disabled" value="">TOPP OWS-5 Demo Service KML 2.2 (states US)</option> 505 505 --> 506 <option value="kml/earth-nh-democrat.kml">Elections NH Democrats</option> 507 <option value="kml/monteray.kml">Monteray: SyleMap and Hotspots</option> 506 508 <option value="kml/sacred.kml">Sacred Destinations</option> 507 509 <option value="kml_elections/aus_nt.kml">Elections NT</option> … … 515 517 <option value="http://featureserver.org/featureserver.cgi/scribble?format=KML">FeatureServer Scribble</option> 516 518 <option value="http://destinsharks.com/kmz/nl/bowlegs_pokerrun.kmz">KMZ Pokerrun (very big)</option> 519 --> 517 520 <option value="http://www.cloudsat.cira.colostate.edu/data_dist/KMLs/dataflow.kmz">KMZ Cloudsat</option> 518 -->519 521 <option value="http://maps.google.com/maps/ms?ie=UTF8&hl=en&om=1&msa=0&output=nl&msid=103763259662194171141.000001119b4b42bf062c2">Google - Route 66 (NetworkLink)</option> 520 522 <option value="http://maps.google.com/maps/ms?ie=UTF8&t=k&hl=en&msa=0&msid=103763259662194171141.000001119b4d1da52255a&output=kml">Google - Monsters</option> … … 529 531 </select> 530 532 <br /> 531 Paste URL: <input type="text" id="url" value=" "/><br />533 Paste URL: <input type="text" id="url" value="kml/conferences.kml"/><br /> 532 534 <input type="button" value="add to layer using url" onclick="loadUrl();" /> 533 535 <br /> sandbox/rdewit/kml/examples/proxy.cgi
r5704 r5792 28 28 method = os.environ["REQUEST_METHOD"] 29 29 30 if method == "POST": 31 qs = os.environ["QUERY_STRING"] 32 d = cgi.parse_qs(qs) 33 if d.has_key("url"): 34 url = d["url"][0] 35 else: 36 url = "http://www.openlayers.org" 30 qs = os.environ["QUERY_STRING"] 31 if method == "GET": 32 qs = qs.replace('+', '%2B') 33 d = cgi.parse_qs(qs) 34 if d.has_key("url"): 35 url = d["url"][0] 37 36 else: 38 fs = cgi.FieldStorage() 39 url = fs.getvalue('url', "http://www.openlayers.org") 37 url = "http://www.openlayers.org" 40 38 41 39 try: sandbox/rdewit/kml/lib/OpenLayers/Format/KML.js
r5704 r5792 227 227 // give feature default style 228 228 feature.style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style["default"]); 229 229 230 230 if (feature.attributes.styleUrl) { 231 231 //console.info(styleUrl, feature.style, this.getStyle(styleUrl)); … … 333 333 "Style"); 334 334 335 var num Styles = styleNodes.length;335 var numNodes = styleNodes.length; 336 336 var styles = {}; 337 337 //console.info("numStyles: " + numStyles); 338 for(var i=0; i<num Styles; i++) {338 for(var i=0; i<numNodes; i++) { 339 339 var style = this.parseStyle(styleNodes[i]); 340 340 if(style) { … … 343 343 } else { 344 344 throw "Bad Placemark: " + i; 345 } 346 } 347 348 // Parse StyleMaps 349 // Only the default or "normal" part of the StyleMap is processed now 350 // To do the select or "highlight" bit, we'd need to change lots more 351 var styleMapNodes = this.getElementsByTagNameNS(data, 352 '*', 353 "StyleMap"); 354 355 var numNodes = styleMapNodes.length; 356 357 for(var i=0; i<numNodes; i++) { 358 var node = styleMapNodes[i]; 359 var pairs = this.getElementsByTagNameNS(node, "*", "Pair"); 360 //console.info(pairs); 361 362 var id = node.getAttribute("id"); 363 for (var j=0; j<pairs.length; j++) { 364 pair = pairs[j]; 365 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"); 370 371 if (key == "normal") { 372 styles[(baseUrl || "") + "#" + id] = styles[(baseUrl || "") + styleUrl]; 373 } 374 375 if (key == "highlight") { 376 //TBD, TODO: implement the "select" part 377 } 378 345 379 } 346 380 } … … 442 476 "*", 443 477 "Icon")[0]; 478 479 // set default width and height of icon 480 style["graphicWidth"] = 32; 481 style["graphicHeight"] = 32; 482 444 483 if (iconNode) { 445 484 hrefNode = this.getElementsByTagNameNS(iconNode, … … 464 503 "*", 465 504 "x")[0]; 466 x = OpenLayers.Util.getXmlNodeValue(xNode);505 var x = OpenLayers.Util.getXmlNodeValue(xNode); 467 506 468 507 var yNode = this.getElementsByTagNameNS(iconNode, 469 508 "*", 470 509 "y")[0]; 471 y = OpenLayers.Util.getXmlNodeValue(yNode);510 var y = OpenLayers.Util.getXmlNodeValue(yNode); 472 511 473 512 var posX = x ? x/32 : 0; … … 490 529 h = OpenLayers.Util.getXmlNodeValue(hNode); 491 530 492 style["graphicWidth"] = w || 20; 493 style["graphicHeight"] = h || null; 494 495 //style["graphicXOffset"] = 0; 496 //style["graphicYOffset"] = 0; 531 if (w) { 532 style["graphicWidth"] = parseInt(w); 533 } 534 535 if (h) { 536 style["graphicHeight"] = parseInt(h); 537 } 497 538 498 539 style["graphicOpacity"] = 1; 499 540 style["externalGraphic"] = href; 500 541 } 542 501 543 } 544 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"]); 576 } 577 578 579 502 580 break; 503 581 case "balloonstyle":
