Changeset 3276
- Timestamp:
- 06/07/07 04:02:37 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/camptocamp/externalGraphics/examples/vector-features.html
r3272 r3276 23 23 style_blue.fillColor = "blue"; 24 24 style_blue.externalGraphic = "../img/marker.png"; 25 26 // each of the three lines below means the same, if only one ot 27 // them is active: the image will have a size of 24px, and the 28 // aspect ratio will be kept 25 29 style_blue.pointRadius = 12; 30 //style_blue.graphicWidth = 24; 31 //style_blue.graphicHeight = 24; 32 33 style_blue.fillOpacity = 1; 26 34 var style_green = { 27 35 strokeColor: "#00FF00", … … 31 39 pointerEvents: "visiblePainted" 32 40 }; 41 var style_mark = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']); 42 43 // if graphicWidth and graphicHeight are both set, the aspect ratio 44 // of the image will be ignored 45 style_mark.graphicWidth = 24; 46 style_mark.graphicHeight = 20; 47 48 style_mark.externalGraphic = "../img/marker.png"; 33 49 34 50 var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry"); … … 40 56 var pointFeature2 = new OpenLayers.Feature.Vector(point2,null,style_green); 41 57 var point3 = new OpenLayers.Geometry.Point(-105.04, 49.68); 42 var pointFeature3 = new OpenLayers.Feature.Vector(point3,null,style_ blue);58 var pointFeature3 = new OpenLayers.Feature.Vector(point3,null,style_mark); 43 59 44 60 // create a line feature from a list of points sandbox/camptocamp/externalGraphics/lib/OpenLayers/Renderer/SVG.js
r3272 r3276 184 184 185 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); 186 if (style.graphicWidth && style.graphicHeight) { 187 node.setAttributeNS(null, "preserveAspectRatio", "none"); 188 } 189 var width = style.graphicWidth || style.graphicHeight; 190 var height = style.graphicHeight || style.graphicWidth; 191 width = width ? width : style.pointRadius*2; 192 height = height ? height : style.pointRadius*2; 193 194 node.setAttributeNS(null, "x", x-(.5*width).toFixed()); 195 node.setAttributeNS(null, "y", -y-(.5*height).toFixed()); 196 node.setAttributeNS(null, "width", width); 197 node.setAttributeNS(null, "height", height); 191 198 node.setAttributeNS("http://www.w3.org/1999/xlink", "href", style.externalGraphic); 192 199 node.setAttributeNS(null, "transform", "scale(1,-1)"); sandbox/camptocamp/externalGraphics/lib/OpenLayers/Renderer/VML.js
r3272 r3276 149 149 fill.src = style.externalGraphic; 150 150 fill.type = "frame"; 151 fill.aspect = "atmost"; 152 node.style.flip = "y"; 151 node.style.flip = "y"; 152 153 if (!(style.graphicWidth && style.graphicHeight)) { 154 fill.aspect = "atmost"; 155 } 153 156 154 157 // now style the new node 155 var radius = style.pointRadius; 158 var width = style.graphicWidth || style.graphicHeight; 159 var height = style.graphicHeight || style.graphicWidth; 160 width = width ? width : style.pointRadius*2; 161 height = height ? height : style.pointRadius*2; 156 162 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;163 node.style.left = (geometry.x/resolution-.5*width).toFixed(); 164 node.style.top = (geometry.y/resolution-.5*height).toFixed(); 165 node.style.width = width; 166 node.style.height = height; 161 167 162 168 // modify fill style for rect styling below
