Created
July 17, 2018 14:57
-
-
Save ramiroaznar/dbccbbb35d2c0fcc62a4b2894f565263 to your computer and use it in GitHub Desktop.
CARTO line styles | CARTO.s v4.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>CARTO line styles | CARTO.s v4.1</title> | |
<meta name="viewport" content="initial-scale=1.0"> | |
<meta charset="utf-8"> | |
<!-- Include Leaflet --> | |
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> | |
<link href="https://unpkg.com/[email protected]/dist/leaflet.css" rel="stylesheet"> | |
<!-- Include CARTO.js --> | |
<script src="https://libs.cartocdn.com/carto.js/v4.1.0/carto.min.js"></script> | |
<style> | |
* { | |
box-sizing: border-box; | |
} | |
body, *{ margin: 0; padding: 0; } | |
#map { | |
position: absolute; | |
height: 100%; | |
width: 100%; | |
z-index: 0; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script> | |
const map = L.map('map').setView([30, 0], 3); | |
map.scrollWheelZoom.disable(); | |
L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}.png', { | |
maxZoom: 18 | |
}).addTo(map); | |
const client = new carto.Client({ | |
apiKey: 'default_public', | |
username: 'ramirocartodb' | |
}); | |
const source = new carto.source.Dataset(` | |
ne_10m_roads | |
`); | |
const style = new carto.style.CartoCSS(` | |
#layer { | |
line-width: 1; | |
line-color: #EE4D5A; | |
line-opacity: 0.7; | |
line-dasharray: 4,2; | |
} | |
`); | |
const layer = new carto.layer.Layer(source, style); | |
client.addLayer(layer); | |
client.getLeafletLayer().addTo(map); | |
const layerStyle = layer.getStyle(); | |
console.log(layerStyle) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment