Select to view content in your preferred language

Can one color be set for a MarkerSymbol with a multiple color SVG file?

672
1
09-08-2020 07:42 AM
ChrisMiller1
New Contributor

I have a set of symbols that I want to draw on a map (ArcGIS 3.x).  They have 2 colors, basically a foreground and background color.  I want to be able to set the background color at runtime. I'm currently using syntax like this:

var mySymbol = new PictureMarkerSymbol('my-symbol.svg', 13, 16);

var myPoint = {
  type: "point",
  longitude: -78.8433227219882,
  latitude: 43.0565610478718
};

var myGraphic = new Graphic({
  geometry: myPoint,
  symbol: mySymbol
});
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I know I can set the color if pass in the path like in the SVG path to create a SimpleMarkerSymbol example

function createSymbol(path, color){
  var markerSymbol = new esri.symbol.SimpleMarkerSymbol();
  markerSymbol.setPath(path);
  markerSymbol.setColor(new dojo.Color(color));
  markerSymbol.setOutline(null);
  return markerSymbol;
}‍‍‍‍‍‍‍

My SVG files have 2 or more paths, so setPath will not work.  Is there another way to pass in the SVG as a datastream?  Basically like an inline SVG image.

Tags (2)
1 Reply
baohuachu2
Emerging Contributor

I have the same requirements. For example to generate a pie chart which has multiple colors.

0 Kudos