OpenLayers OpenLayers

Ticket #736: vectorimages.diff

File vectorimages.diff, 3.4 kB (added by openlayers, 1 year ago)
  • /mnt/d/eclipse/workspace/openlayers/examples/vector-features.html

    old new  
    2121            var style_blue = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']); 
    2222            style_blue.strokeColor = "blue";  
    2323            style_blue.fillColor = "blue";  
     24            style_blue.externalGraphic = "../img/marker.png"; 
     25            style_blue.pointRadius = 12; 
    2426            var style_green = { 
    2527                strokeColor: "#00FF00", 
    2628                strokeOpacity: 1, 
     
    3436            // create a point feature 
    3537            var point = new OpenLayers.Geometry.Point(-111.04, 45.68); 
    3638            var pointFeature = new OpenLayers.Feature.Vector(point,null,style_blue); 
     39            var point2 = new OpenLayers.Geometry.Point(-110.04, 44.68); 
     40            var pointFeature2 = new OpenLayers.Feature.Vector(point2,null,style_green); 
    3741             
    3842            // create a line feature from a list of points 
    3943            var pointList = []; 
     
    6468             
    6569            map.addLayer(vectorLayer); 
    6670            map.setCenter(new OpenLayers.LonLat(point.x, point.y), 5); 
    67             vectorLayer.addFeatures([pointFeature, lineFeature, polygonFeature]); 
     71            vectorLayer.addFeatures([pointFeature, pointFeature2, lineFeature, polygonFeature]); 
    6872        } 
    6973        // --> 
    7074    </script> 
  • /mnt/d/eclipse/workspace/openlayers/lib/OpenLayers/Renderer/SVG.js

    old new  
    165165        options = options || node._options; 
    166166 
    167167        if (node._geometryClass == "OpenLayers.Geometry.Point") { 
    168             node.setAttributeNS(null, "r", style.pointRadius); 
     168                alert(node.getAttributeNS(null, "id")); 
     169            if (style.externalGraphic) { 
     170                // remove old node 
     171                var id = node.getAttributeNS(null, "id"); 
     172                var x = node.getAttributeNS(null, "cx"); 
     173                var y = node.getAttributeNS(null, "cy"); 
     174                var _featureId = node._featureId; 
     175                var _geometryClass = node._geometryClass; 
     176                var _style = node._style; 
     177                this.root.removeChild(node); 
     178                 
     179                // create new image node 
     180                var node = this.createNode("image", id); 
     181                node._featureId = _featureId; 
     182                node._geometryClass = _geometryClass; 
     183                node._style = _style; 
     184                this.root.appendChild(node); 
     185 
     186                // now style the new node 
     187                node.setAttributeNS(null, "x", x-style.pointRadius); 
     188                node.setAttributeNS(null, "y", y-style.pointRadius); 
     189                node.setAttributeNS(null, "width", 2*style.pointRadius); 
     190                node.setAttributeNS(null, "height", 2*style.pointRadius); 
     191                node.setAttributeNS("http://www.w3.org/1999/xlink", "href", style.externalGraphic); 
     192            } else { 
     193                node.setAttributeNS(null, "r", style.pointRadius); 
     194            } 
    169195        } 
    170196         
    171197        if (options.isFilled) {