Select to view content in your preferred language

Red line with black outline in JavaScript API

1467
5
Jump to solution
10-20-2016 09:48 PM
PitersonPaulgek
New Contributor III

Hi,

We need to draw roads as a red line with black outline (or stroke) (see attached) with ESRI JavaScript API.

Something like that (example from leaflet - Leaflet.MapboxVectorTile.js):

drawLineString = function(....){

....

var ctx2d = ctx.canvas.getContext('2d');
ctx2d.strokeStyle = style.color;
ctx2d.lineWidth = style.size;
ctx2d.beginPath();

ctx2d.stroke();

if (style.outlineWidth && style.outlineColor) {
  ctx2d.lineWidth = style.outlineWidth;
  ctx2d.strokeStyle = style.outlineColor;
  ctx2d.stroke();

...
};

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

It's a different API with different capabilities.

View solution in original post

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus

Piterson,

  There is nothing in the JS for setting a stroke on a line. The best you can do it add the line graphic twice using different SimpleLineSymbols with different widths and colors.

0 Kudos
PitersonPaulgek
New Contributor III

Thanks Robert,

It means we have no access to the library that draw the geometry?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Piterson,

   No, you just dont have the ability to define a line symbol that has a separate outline color.

0 Kudos
PitersonPaulgek
New Contributor III

Why it is possible for Leaflet.MapboxVectorTile.js?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

It's a different API with different capabilities.

0 Kudos