Skip to content
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

Separate colors for stroke, fill #105

Open
chaitanya1248 opened this issue May 21, 2020 · 1 comment
Open

Separate colors for stroke, fill #105

chaitanya1248 opened this issue May 21, 2020 · 1 comment

Comments

@chaitanya1248
Copy link

chaitanya1248 commented May 21, 2020

I've added arrowheads along the path of a GeoJson. I'm wondering if there is a way to customize the stroke color to be different from fill color?

Here are the options I tried:

        {
          offset: "20%",
          repeat: "30%",
          symbol: L.Symbol.arrowHead({
            pixelSize: zoom * 2,
            pathOptions: {
              fillOpacity: 1,
              weight: 0,
              // fill: true,
              // fillColor: "#c71002",
              color: "#c71002",
              stroke: true,
              strokeColor: "#fff"
            }
          })
        }
      ]
@miko866
Copy link

miko866 commented May 27, 2020

Try this code but it's static.

 let arrow = L.polylineDecorator(layer, {
                id: layer._leaflet_id,
                patterns: [
                  {
                    offset: '100%',
                    endOffset: '100%',
                    repeat: 0,
                    symbol: L.Symbol.arrowHead({
                      pixelSize: 15,
                      polygon: false,
                      pathOptions: {
                        fill: false,
                        fillColor: '',
                        fillOpacity: 1,
                        stroke: true,
                        color: feature.properties.color,
                        opacity: 1,
                        weight: 5,
                        lineCap: 'square',
                        lineJoin: 'miter',
                      },
                    }),
                  },
                ],
              }).addTo(vm.map);

If you want it dynamically you will need something so:

  this.arrowHeads.map((arrow) => {
        if (arrow.options.id === this.layerShape._leaflet_id) {
          arrow.options.patterns[0].symbol.options.pathOptions.weight = val;
        // Refresh map after update arrow value
          this.map.fitBounds(this.map.getBounds());
        }
      });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants