How to customize vector data 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: () => {
const overlayManager = core.getOverlayManager();
const customStyle = new Vexcel.Style.Style({
fill: new Vexcel.Style.Fill({ color: "rgba(23,227,91,0.6)"}),
stroke: new Vexcel.Style.Stroke({
color: "#ec1c1c",
width: 2,
}),
});
const lineGeometry = new Vexcel.Geometry.Line([
new Vexcel.Geometry.Location(30.770159115784214, -86.6162109375),
new Vexcel.Geometry.Location(31.914867503276223, -88.57177734375),
new Vexcel.Geometry.Location(33.50475906922609, -87.2094726562),
]);
const ring = [
new Vexcel.Geometry.Location(32.36140331527543, -84.44091796875),
new Vexcel.Geometry.Location(32.36140331527543, -82.529296875),
new Vexcel.Geometry.Location(33.87041555094183, -82.529296875),
new Vexcel.Geometry.Location(33.87041555094183, -84.44091796875),
new Vexcel.Geometry.Location(32.36140331527543, -84.44091796875),
];
const ring2 = [
new Vexcel.Geometry.Location(31.55981453201843, -87.0556640625),
new Vexcel.Geometry.Location(31.55981453201843, -85.166015625),
new Vexcel.Geometry.Location(32.861132322810946, -85.166015625),
new Vexcel.Geometry.Location(32.861132322810946, -87.0556640625),
new Vexcel.Geometry.Location(31.55981453201843, -87.0556640625),
];
const hole = [
new Vexcel.Geometry.Location(31.952162238024975, -86.41845703124999),
new Vexcel.Geometry.Location(31.952162238024975, -85.78125),
new Vexcel.Geometry.Location(32.47269502206151, -85.78125),
new Vexcel.Geometry.Location(32.47269502206151, -86.41845703124999),
new Vexcel.Geometry.Location(31.952162238024975, -86.41845703124999),
];
const polygonGeom = new Vexcel.Geometry.Polygon([ring]);
const polygonWithHoleGeom = new Vexcel.Geometry.Polygon([ring2, hole]);
const multipolygonGeometry = new Vexcel.Geometry.MultiPolygon([
[
[
new Vexcel.Geometry.Location(35.585851593232356, -116.136474609375),
new Vexcel.Geometry.Location(35.15584570226544, -117.39990234375),
new Vexcel.Geometry.Location(35.02999636902566, -115.631103515625),
new Vexcel.Geometry.Location(35.585851593232356, -116.136474609375),
],
[
new Vexcel.Geometry.Location(35.737595151747826, -115.224609375),
new Vexcel.Geometry.Location(35.08395557927643, -114.686279296875),
new Vexcel.Geometry.Location(35.746512259918504, -113.97216796875),
new Vexcel.Geometry.Location(35.737595151747826, -115.224609375),
],
],
]);
const polygon = new Vexcel.Feature(polygonGeom);
const polygonWithHole = new Vexcel.Feature(polygonWithHoleGeom);
const line = new Vexcel.Feature(lineGeometry);
const multipolygon = new Vexcel.Feature(multipolygonGeometry);
const vectorLayer = new Vexcel.Layers.VectorLayer({
visible: true,
features: [polygon, polygonWithHole, line, multipolygon],
style: [customStyle],
});
overlayManager.addLayer(vectorLayer);
},
},
});