-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Way to use external svg file #28
Comments
Yes, this plugin creates its own SVG object: https://github.com/openseadragon/svg-overlay/blob/master/openseadragon-svg-overlay.js#L34 One approach would be to pull the elements you want out of the SVG object you're loading via ajax and stuffing those into the SVG object the plugin creates. If you nest everything inside of a Another option would be to modify this plugin so you can pass in an SVG element for it to use instead. The plugin is very small, so it should be an easy code change if you want to go that way, and I'd be happy to merge such a patch if you wanted to make a pull request. |
Hi Ian: Well I prefer to use the first approach , that is, to parse the SVG file pulling out the contents I need to draw. Anyway, trying to implement that is not working: But following the same technique using a regular html svg element, (svgBlock) as container, instead overlay.node(), perfectly works: Any help on this? Best regards. |
Hi Ian: I can see that when using the xhr.response directly to a svg block (not OSD at all), my code looks like this: And when I load it on the OSD overlay (overlay.node()), it is the following: So basically, the "bird" is there but is scaled or positioned in a way it can´t be seen over the OSD canvas. The case is that the transform "figures" (translate(-371.94953627932824,-119.01136570285395) scale(1837.0000000000002) rotate(0)) seem to be correct. However, deleting that transform node makes the trick, and the bird is shown then. As that transform node is added by OSD, and I suppose it is the basis for the zoom-pan functionality, how can I get rid of this behavior? |
I see! Yes, that transform is what aligns the SVG with the zoom/pan of the OSD object. To be precise, what it does is set your SVG to the viewport coordinate system of your OSD. If your SVG path isn't naturally in those viewport coordinates (because it's too big or too small), you have a couple of options: you can change your OSD viewport coordinate system, or you can scale your path. To change the OSD viewport coordinates, you specify a different size for your image. By default the image is 1 unit wide. If you wanted 1000 units wide, you could do this:
On the other hand, if you want to transform your path instead, you can add a You might even use a combination of the two techniques, changing the OSD coordinates to be a more comfortable scale, but also putting a translate transform on your path to make sure it is positioned properly. BTW, for more info on viewport coordinates see: http://openseadragon.github.io/examples/viewport-coordinates/ |
Well, I'm here again with the OSD part (among many) of this project. First of all, thanks for your explanation!, Ian. In order to keep the things simple and efficient, I'm trying to keep the same OSV Viewer settings, meanwhile toggling between the PNG (simple image, not pyramidal one) and the SVG visualization. Said this, I assume the best solution is the second you have mentioned, as It can be done with not programming at all, in the SVG authoring stage of the workflow. Said this, I'd like also to check the "tilesource width solution". Before going with the SVG part, I need to check whether changing the things, as you are instruct me, breaks my code down or not for the PNG part. Sadly, I've tried to change the width of the image without luck. The case is that I implement "creation plus photo loading" in a two-stages pattern. First:
and then, when needed:
Said this, where must it be the "width" property set, in OSD constructor (stage 1) or when actually opening the file (stage 2)? As said, I've tried both approach without any luck. Thank you for your time. P.S. I'm sorry for the lack of indentation in the code blocks. It is there meanwhile writing but not shown in preview (?) |
To make your viewer width, say, 1000, you could do:
This can work in the OSD constructor as well, if that's when you're adding the image... basically you do it wherever you add the image. I've gone ahead and fixed the indentation in your comment... you just use ```. |
Thanks again Ian. I'll check it this weekend. |
Hi there Ian:
We're using your excellent pan-zoom framework in a development which manages assets in a side-by-side basis, using PNGs and SVGs. Of course, PNG's part is piece of cake, but I'm having problems in the SVG part.
Our SVGs are external files, wich we need to "ajax" in order to have the advantage of media-caching and the ability to tweak styles through CSS (not inline SVG or img translation are covered here).
This way We're "ajaxing" the SVG under the general algorithm to insert an external SVG in an HTML page:
The case is that under this approach I'm creating a node with all the header , symbols, etc..., and I suspect the overlay.node() SVG surface is waiting for SVG primitives only. So we had to parse our SVGs and add the different elements (path, rect, line, ...) one after the other. Isn´t it?
Best regards.
The text was updated successfully, but these errors were encountered: