Ticket #736: externalGraphic.diff
| File externalGraphic.diff, 6.2 kB (added by ahocevar, 1 year ago) |
|---|
-
/mnt/d/eclipse/workspace/openlayers/examples/vector-features.html
old new 21 21 var style_blue = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']); 22 22 style_blue.strokeColor = "blue"; 23 23 style_blue.fillColor = "blue"; 24 style_blue.externalGraphic = "../img/marker.png"; 25 style_blue.pointRadius = 12; 24 26 var style_green = { 25 27 strokeColor: "#00FF00", 26 28 strokeOpacity: 1, … … 34 36 // create a point feature 35 37 var point = new OpenLayers.Geometry.Point(-111.04, 45.68); 36 38 var pointFeature = new OpenLayers.Feature.Vector(point,null,style_blue); 39 var point2 = new OpenLayers.Geometry.Point(-105.04, 49.68); 40 var pointFeature2 = new OpenLayers.Feature.Vector(point2,null,style_green); 41 var point3 = new OpenLayers.Geometry.Point(-105.04, 49.68); 42 var pointFeature3 = new OpenLayers.Feature.Vector(point3,null,style_blue); 37 43 38 44 // create a line feature from a list of points 39 45 var pointList = []; … … 64 70 65 71 map.addLayer(vectorLayer); 66 72 map.setCenter(new OpenLayers.LonLat(point.x, point.y), 5); 67 vectorLayer.addFeatures([pointFeature, lineFeature, polygonFeature]);73 vectorLayer.addFeatures([pointFeature, pointFeature3, pointFeature2, lineFeature, polygonFeature]); 68 74 } 69 75 // --> 70 76 </script> -
/mnt/d/eclipse/workspace/openlayers/lib/OpenLayers/Renderer/SVG.js
old new 165 165 options = options || node._options; 166 166 167 167 if (node._geometryClass == "OpenLayers.Geometry.Point") { 168 node.setAttributeNS(null, "r", style.pointRadius); 168 if (style.externalGraphic) { 169 // remove old node 170 var id = node.getAttributeNS(null, "id"); 171 var x = node.getAttributeNS(null, "cx"); 172 var y = node.getAttributeNS(null, "cy"); 173 var _featureId = node._featureId; 174 var _geometryClass = node._geometryClass; 175 var _style = node._style; 176 this.root.removeChild(node); 177 178 // create new image node 179 var node = this.createNode("image", id); 180 node._featureId = _featureId; 181 node._geometryClass = _geometryClass; 182 node._style = _style; 183 this.root.appendChild(node); 184 185 // now style the new node 186 var radius = style.pointRadius; 187 node.setAttributeNS(null, "x", x-radius); 188 node.setAttributeNS(null, "y", -y-radius); 189 node.setAttributeNS(null, "width", 2*radius); 190 node.setAttributeNS(null, "height", 2*radius); 191 node.setAttributeNS("http://www.w3.org/1999/xlink", "href", style.externalGraphic); 192 node.setAttributeNS(null, "transform", "scale(1,-1)"); 193 node.setAttributeNS(null, "style", "opacity: "+style.fillOpacity); 194 } else { 195 node.setAttributeNS(null, "r", style.pointRadius); 196 } 169 197 } 170 198 171 199 if (options.isFilled) { -
/mnt/d/eclipse/workspace/openlayers/lib/OpenLayers/Renderer/VML.js
old new 129 129 options = options || node._options; 130 130 131 131 if (node._geometryClass == "OpenLayers.Geometry.Point") { 132 this.drawCircle(node, geometry, style.pointRadius); 132 if (style.externalGraphic) { 133 // remove old node 134 var id = node.id; 135 var _featureId = node._featureId; 136 var _geometryClass = node._geometryClass; 137 var _style = node._style; 138 this.root.removeChild(node); 139 140 // create new image node 141 var node = this.createNode("v:rect", id); 142 var fill = this.createNode("v:fill", id+"_image"); 143 node.appendChild(fill); 144 node._featureId = _featureId; 145 node._geometryClass = _geometryClass; 146 node._style = _style; 147 this.root.appendChild(node); 148 149 fill.src = style.externalGraphic; 150 fill.type = "frame"; 151 fill.aspect = "atmost"; 152 node.style.flip = "y"; 153 154 // now style the new node 155 var radius = style.pointRadius; 156 var resolution = this.getResolution(); 157 node.style.left = (geometry.x/resolution-radius).toFixed(); 158 node.style.top = (geometry.y/resolution-radius).toFixed(); 159 node.style.width = 2*radius; 160 node.style.height = 2*radius; 161 162 // modify fill style for rect styling below 163 style.fillColor = "none"; 164 style.strokeColor = "none"; 165 166 } else { 167 this.drawCircle(node, geometry, style.pointRadius); 168 } 133 169 } 134 170 135 171 //fill … … 146 182 fill = this.createNode('v:fill', node.id + "_fill"); 147 183 node.appendChild(fill); 148 184 } 149 fill.setAttribute("opacity", style.fillOpacity); 185 if (style.fillOpacity) { 186 fill.setAttribute("opacity", style.fillOpacity); 187 } 150 188 } 151 189 152 190
