OpenLayers OpenLayers

Changeset 5792

Show
Ignore:
Timestamp:
01/16/08 21:19:30 (11 months ago)
Author:
rdewit
Message:

updates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/rdewit/kml/examples/kml_wmsc_ows5.html

    r5704 r5792  
    108108        var loadingLayers = 0; 
    109109 
    110         //OpenLayers.ProxyHost = "proxy.php?url="; 
    111110        //OpenLayers.ProxyHost = "/mapbuilder/MapbuilderProxy.jsp?url="; 
    112111        OpenLayers.ProxyHost = "proxy.cgi?url="; 
     112        //OpenLayers.ProxyHost = "proxy.php?url="; 
    113113 
    114114        var wmscURL = "http://geo.openplans.org:8080/geoserver/wms"; 
     
    201201        function onFeatureSelect(feature) { 
    202202            selectedFeature = feature; 
    203  
    204203            var content;  
    205204            if (feature.style.balloonStyle) { 
     
    307306            var url = element.value; 
    308307            increaseLoadingLayers(); 
     308            //url = url.replace(/\+/, "%2B"); // escape the '+' character 
    309309            OpenLayers.loadURL(url, null, null, loadUrlSuccess, loadUrlFailure); 
    310310        } 
     
    504504                <option disabled="disabled" value="">TOPP OWS-5 Demo Service KML 2.2 (states US)</option> 
    505505                --> 
     506                <option value="kml/earth-nh-democrat.kml">Elections NH Democrats</option> 
     507                <option value="kml/monteray.kml">Monteray: SyleMap and Hotspots</option> 
    506508                <option value="kml/sacred.kml">Sacred Destinations</option> 
    507509                <option value="kml_elections/aus_nt.kml">Elections NT</option> 
     
    515517                <option value="http://featureserver.org/featureserver.cgi/scribble?format=KML">FeatureServer Scribble</option> 
    516518                <option value="http://destinsharks.com/kmz/nl/bowlegs_pokerrun.kmz">KMZ Pokerrun (very big)</option> 
     519                --> 
    517520                <option value="http://www.cloudsat.cira.colostate.edu/data_dist/KMLs/dataflow.kmz">KMZ Cloudsat</option> 
    518                 --> 
    519521                <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> 
    520522                <option value="http://maps.google.com/maps/ms?ie=UTF8&t=k&hl=en&msa=0&msid=103763259662194171141.000001119b4d1da52255a&output=kml">Google - Monsters</option> 
     
    529531            </select> 
    530532            <br /> 
    531             Paste URL: <input type="text" id="url" value=""/><br /> 
     533            Paste URL: <input type="text" id="url" value="kml/conferences.kml"/><br /> 
    532534            <input type="button" value="add to layer using url" onclick="loadUrl();" /> 
    533535            <br /> 
  • sandbox/rdewit/kml/examples/proxy.cgi

    r5704 r5792  
    2828method = os.environ["REQUEST_METHOD"] 
    2929 
    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" 
     30qs = os.environ["QUERY_STRING"] 
     31if method == "GET": 
     32    qs = qs.replace('+', '%2B') 
     33d = cgi.parse_qs(qs) 
     34if d.has_key("url"): 
     35    url = d["url"][0] 
    3736else: 
    38     fs = cgi.FieldStorage() 
    39     url = fs.getvalue('url', "http://www.openlayers.org") 
     37    url = "http://www.openlayers.org" 
    4038 
    4139try: 
  • sandbox/rdewit/kml/lib/OpenLayers/Format/KML.js

    r5704 r5792  
    227227                // give feature default style 
    228228                feature.style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style["default"]); 
    229              
     229                  
    230230                if (feature.attributes.styleUrl) { 
    231231                    //console.info(styleUrl, feature.style, this.getStyle(styleUrl)); 
     
    333333                                                       "Style"); 
    334334 
    335         var numStyles = styleNodes.length; 
     335        var numNodes = styleNodes.length; 
    336336        var styles = {}; 
    337337        //console.info("numStyles: " + numStyles); 
    338         for(var i=0; i<numStyles; i++) { 
     338        for(var i=0; i<numNodes; i++) { 
    339339            var style = this.parseStyle(styleNodes[i]); 
    340340            if(style) { 
     
    343343            } else { 
    344344                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 
    345379            } 
    346380        } 
     
    442476                                                   "*",  
    443477                                                   "Icon")[0]; 
     478 
     479                        // set default width and height of icon 
     480                        style["graphicWidth"] = 32; 
     481                        style["graphicHeight"] = 32; 
     482 
    444483                        if (iconNode) { 
    445484                            hrefNode = this.getElementsByTagNameNS(iconNode,  
     
    464503                                                           "*",  
    465504                                                           "x")[0]; 
    466                                     x = OpenLayers.Util.getXmlNodeValue(xNode); 
     505                                    var x = OpenLayers.Util.getXmlNodeValue(xNode); 
    467506 
    468507                                    var yNode = this.getElementsByTagNameNS(iconNode,  
    469508                                                           "*",  
    470509                                                           "y")[0]; 
    471                                     y = OpenLayers.Util.getXmlNodeValue(yNode); 
     510                                    var y = OpenLayers.Util.getXmlNodeValue(yNode); 
    472511 
    473512                                    var posX = x ? x/32 : 0; 
     
    490529                                h = OpenLayers.Util.getXmlNodeValue(hNode); 
    491530 
    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                                } 
    497538 
    498539                                style["graphicOpacity"] = 1; 
    499540                                style["externalGraphic"] = href; 
    500541                            } 
     542 
    501543                        } 
     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                             
    502580                        break; 
    503581                    case "balloonstyle":