How to customize features styles
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://app.vexcelgroup.com/map/v2/public/css/styles.css" type="text/css"/>
<style>
.map {
height: 800px;
overflow: hidden;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script type="text/javascript" src="https://app.vexcelgroup.com/map/v2/public/Vexcel.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
main.js
const API_KEY = "YOUR_KEY";
const core = new Vexcel.Map({
target: "map",
token: API_KEY,
initialConfig: {
overlays: {
visible: [],
},
imageryLayers: {
visible: [],
},
callback: () => {
function styleFunction(feature, resolution) {
return new Vexcel.Style.Style({
fill: new Vexcel.Style.Fill({ color: "rgba(255, 0, 0, 0.4)" }),
stroke: new Vexcel.Style.Stroke({ color: "rgba(255, 0, 0, 1)", width: 2 }),
image: new Vexcel.Style.Circle({
radius: 10,
fill: new Vexcel.Style.Fill({ color: "rgba(255, 0, 0, 0.4)" }),
stroke: new Vexcel.Style.Stroke({ color: "rgba(255, 0, 0, 1)", width: 1 }),
}),
text: new Vexcel.Style.Text({
text: feature.get("title"),
fill: new Vexcel.Style.Fill({
color: "black",
}),
stroke: new Vexcel.Style.Stroke({ color: "white", width: 1 }),
}),
});
}
const vectorLayer = new Vexcel.Layers.VectorLayer({
url: "data/vector-sample.json",
style: styleFunction,
});
core.getOverlayManager().addLayer(vectorLayer);
},
},
});