I am trying to set the externalGraphic property of a vector layer's style to an SVG sprite that has various viewboxes to position the icons dynamically by creating different views within my SVG file:
<view id="bikeview" viewBox="0 0 52 52"></view>
<view id="boatview" viewBox="52 0 52 52"></view>
...and then accessing them like so:
var defPoiStyle = {
externalGraphic: 'images/activities/activitySprite.svg#boatview',
pointRadius: 30,
cursor: "pointer"
}
The problem is that this only works in Firefox, although with Chrome and Safari I can access each view by entering the URL directly into the browser like this, just not in the map.
I have also noticed that in Chrome's network log (and likely Safari's) that the #boatview
part of my image path gets stripped out, but not so in Firefox. I assume it is some kind of XML request issue or something, but I feel like I got my declarations right:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px"
y="0px"
width="52px"
height="52px"
id="svg3753"
version="1.1">
This is too complicated for jsFiddle, but here is my map. Give it a go in Chrome and then in Firefox, and you should see what I mean (the boat icon is what is supposed to display).