How to style path in leaflet? - css

I have line geometry that I've styled using the dashArray option. I'm trying to add a black outline to distinguish the gaps on lighter basemaps.
I tried adding a black path underneath with a heavier weight to create the outline but it seems that the gaps are transparent.
Applying the following style to the respective layers creates a white line with a black outline:
path = {
color: '#ffffff',
weight: 3,
opacity: 1
}
outline = {
color: '#000000',
weight: 5,
opacity: 1
}
When I apply dashArray the bottom layer shows through:
path = {
color: '#000000',
weight: 3,
opacity: 1,
dashArray: '5,10'
}
outline = {
color: '#000000',
weight: 5,
opacity: 1
}
Is there a simple way to achieve this?
Leaflet path style options here.
EDIT: Top path is dashArray by itself. Second is when I overlay the dashArray on the wider black line (outline). Third is what I'm trying to achieve.

You could achieve the same effect with just 2 paths:
Background, continuous and wider.
Foreground, dashed and narrower. The background is visible through the gaps.
It is not exactly the same result, since if you want round caps, it is the white dashes that get them. But if you want actually square caps, as shown below, then you get the same effect:
var map = L.map("map").setView([0.4, 0], 8);
var coords = [
[0, -1],
[0, 1],
[1, 1]
];
// Background continuous black stroke, wider than dashed line.
L.polyline(coords, {
weight: 10,
lineCap: 'square', // Optional, just to avoid round borders.
color: 'black'
}).addTo(map);
// Foreground dashed white stroke, narrower than background.
L.polyline(coords, {
weight: 6,
dashArray: '5, 10',
lineCap: 'square', // Optional, just to avoid round borders.
color: 'white'
}).addTo(map);
<link rel="stylesheet" href="https://unpkg.com/leaflet#1.2.0/dist/leaflet.css">
<script src="https://unpkg.com/leaflet#1.2.0/dist/leaflet-src.js"></script>
<div id="map" style="height: 200px"></div>

The solution I came up with combines the two examples using three layers placing the dashArray path on top of the black-outlined layer.
//base layer black & wider to create outline
outline = {
color: '#000000',
weight: 5,
opacity: 1
}
//white line layer that will show through the transparent gaps
pathBackground = {
color: '#ffffff',
weight: 3,
opacity: 1
}
//dashed path is placed on top of the black-outlined white line
path = {
color: '#000000',
weight: 3,
opacity: 1,
dashArray: '5,10'
}

Related

Unset fill black

The Google Visualization Chart is filled with a color if the fill css property is set, e.g.
* {
fill: black;
}
Is there a way to unset the CSS fill property so that it uses the original colors? The goal is not to modify the Chart component is any way, the fill is unrelated to the chart (can be used to change other SVGs) but it affects the chart.
This does not work:
#chart_div * {
fill: unset;
}
See this fiddle: https://jsfiddle.net/g37fjyLx/1/
I realize that setting the fill for all elements * is probably not a good idea, but I'd still like to know if there is a way to reset it.
you need to use backgroundColor.fill. Please refer this https://developers.google.com/chart/interactive/docs/gallery/ganttchart#configuration-options
var options = {
height: 275,
backgroundColor: { fill: "#333" }
};
use this for your color:
var options = {
height: 275,
gantt: {
criticalPathEnabled: false, // Critical path arrows will be the same as other arrows.
arrow: {
angle: 100,
width: 5,
color: 'blue',
radius: 0
}
}
};

Set the thickness of ant design icons in CSS

Attached Image of icon to set the thickness
I have tried to set the thickness of the circle using stroke and stroke-width in css but none of them worked. The icon is imported from the antdesign .
Anybody can help with this? Much appreciated. Thanks
Currently my code looks like this(React)
<PlusCircleOutlined
style={{
fontSize: "50px",
color: "#408021",
storke: "#408021",
strokeWidth: "2px",
}}
/>
enter code here
You have a typo error "storke", should be "stroke", but this is not the problem. To make the lines more thickness you will need to use the stroke property equal white or equal to the background color to erase part of the filled area:
<PlusCircleOutlined style={{
fontSize: "50px",
color: "#408021",
strokeWidth: "30", // --> higher value === more thickness the filled area
stroke: "white"
}}/>
Looks like you have a typo: storke: "#408021". Update that to stroke and it should work.
I always prefer to keep my styles in the css, so I did:
-In my jsx:
<PlusCircleOutlined className="icon-bold" />
-And in my styles:
.icon-bold {
stroke-width: 25;
stroke: black;
color: black;
}

leaflet tile layer add background color using Css class

How can I add a custom background color for the maps tile layers. using css class?
function initLayer(item, map) {
const stateLayer = L.geoJSON(item, {
style: function(feature) {
return {
weight: 8,
opacity: 1,
color: '#333',
fillOpacity: 1,
className: 'gradient-class' // add custom class
}
},
});
map.addLayer(stateLayer);
}
You can change the background of the map. (By default the grey background when loading tiles)
#map{
background-color: #bb4040;
}
If you wnat to change the tile color you can use a css filter: https://stackoverflow.com/a/60431006/8283938

Style Shape in Sketch from CSS

I have this CSS :
shadowColor: '#444',
shadowOffset: { width: 5, height: 5 },
shadowOpacity: 0.2,
shadowRadius: 8,
backgroundColor: 'white',
borderRadius: 10,
I'd like to replicate this style on Sketch.
But it uses 'Blur' and 'Spread' property for the shadow.
And i've noticed it uses box-shadow if you try to do it manually.
My question is :
I have this CSS styling. How could i apply it to my Shape.
(with or without plugin)
Sketch Version 47.1
For me, the style that you have would be translated like this in sketch app :
shadowColor: '#444', // Color #444
shadowOffset: { width: 5, height: 5 }, // X & Y offset to 5px
shadowOpacity: 0.2, // Opacity 20 (the A in HSBA)
shadowRadius: 8, // Look like it's the Blur
backgroundColor: 'white', // Bg color of the shape
borderRadius: 10, // Border radius of the shape
It is what you need ?
PS : This is not some CSS syntax that you have in your code.

Open Layers: fill polygon not truly transparent, more like white with opacity

As you can see in the image, the color is not 'transparent', it just looks like open layers default color fill, white with opacity.
I need my polygon to be full transparent.
Any help?
var style = new ol.style.Style({
fill: new ol.style.Fill({
color:'transparent'
}),
stroke: new ol.style.Stroke({
color: 'white',
width: 1
})
});
'transparent' is not a valid color. If you do not want a fill, simply don't configure a fill with your style:
var style = new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'white',
width: 1
})
});

Resources