You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to use a glyphicon (commercial icon set) SVG icon as an icon in a openlayer map.
This fails becuase the SVG files have no dimension data (width / height) in the file itself:
But this is not really feasible in my situation, because this is an external (and thus fixed) set of SVG files which I would rather not have to touch on every update. Also, adding width and height to these files degrades their usefulness since they are supposed to be used in a wide range of different sizes. They are supposed to not have any dimensions.
What I would have expected is that openlayers would use the dimensions that I have provided in the instantiation of the Icon object, but they seem to have no effect when loading the SVG file:
image: new Icon({
...
width: 32, // These dimensions should be used to create the canvas,
height: 32, // instead of the (non-existing) dimensions from the SVG file.
}),
Used openlayers versions (excerpt from yarn list):
That is a Firefox issue. Unsized SVGs cannot be drawn to canvas in any application. Additionally they cannot be scaled in 2 dimensions unless the preserveAspectRatio attribute is explicitly set to none. Although unsized SVGs can be drawn to canvas in other browsers the results can be inconsistent, e.g. in Chrome they may be sized based on the size of the canvas. If you must use them you will need a custom loader to inject appropriate defaults for consistent results. See #14933 for an example.
I try to use a glyphicon (commercial icon set) SVG icon as an icon in a openlayer map.
This fails becuase the SVG files have no dimension data (width / height) in the file itself:
Trying to load this SVG file as an icon in openlayers as such ...:
... fails with this error:
This error can (theoretically) be resolved if I add a
width
andheight
to the SVG file itself:But this is not really feasible in my situation, because this is an external (and thus fixed) set of SVG files which I would rather not have to touch on every update. Also, adding width and height to these files degrades their usefulness since they are supposed to be used in a wide range of different sizes. They are supposed to not have any dimensions.
What I would have expected is that openlayers would use the dimensions that I have provided in the instantiation of the
Icon
object, but they seem to have no effect when loading the SVG file:Used openlayers versions (excerpt from
yarn list
):Tested in Firefox 125.0.3 (64-Bit)
The text was updated successfully, but these errors were encountered: