isn't this the same? adding 1 image or adding 6 images? I am sure you are good enough and figure out how to add 6 images, if you know how to add one image.

just query the bbox and then place the images around the corners of the bbox. Maybe you can also use markers, depending on your requirements.

Here is the code to add one image:

var bbox = shape.getBBox(); //shape needs to be an existing node reference to a geometry element
var image = document.createElementNS("http://www.w3.org/2000/svg","image";);
var imageWidth = 10; //replace this with your desired image width
image.setAttributeNS(null,"x",bbox.x - imageWidth * 0.5);
image.setAttributeNS(null,"y",bbox.y - imageWidth * 0.5);
image.setAttributeNS(null,"width",imageWidth);
image.setAttributeNS(null,"height",imageWidth);
image.setAttributeNS("http://www.w3.org/1999/xlink","href","myUpperLeftArrow.png";);
parentGroup.appendChild(image); //parentGroup needs to be an existing node reference to a group where the images should be appended

Hope this helps,
Andreas

Hi Peppe,

http://www.carto.net/papers/svg/manipulating_svg_with_dom_ecmascript/index.shtml

contains a tutorial on how to manipulate the DOM with Javascript. Althought this targets ECMAScript, the same methods also apply to Java.

In your example, the bbox does not really exist. It is a SVGRect object (with x,y,width,height) properties. You need to add your new image somewhere in the DOM, using methods like .appendChild() or .insertBefore(). Be aware that images use the xlink namespace when you specify the "href" attribute. You have to explicitly set the namespace for this attribute, e.g.

image.setAttributeNS("http://www.w3.org/1999/xlink","href","myImage.png";);

Hope this helps,
Andreas



i don't add a rect image, i need to add six arrows (that are 6 jpeg file)
around the bbox's border. So, i need to add all object properties
(x,y,width, height) but then i need to add these arrow around the bbox


--
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093  Zurich, Switzerland

Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: [EMAIL PROTECTED]
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to