fix: drawPath method
Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com>
This commit is contained in:
parent
33cb7e82b4
commit
52958a2317
1 changed files with 100 additions and 91 deletions
|
|
@ -443,9 +443,7 @@ const drawMarkers = async (ctx, markers, z) => {
|
|||
* @param {number} z Map zoom level.
|
||||
*/
|
||||
const drawPath = (ctx, path, query, z) => {
|
||||
// Check if path in query is valid
|
||||
const splitPaths = query.path.split('|');
|
||||
|
||||
const renderPath = (splitPaths) => {
|
||||
if (!path || path.length < 2) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -467,7 +465,8 @@ const drawPath = (ctx, path, query, z) => {
|
|||
}
|
||||
|
||||
// Optionally fill drawn shape with a rgba color from query
|
||||
const pathHasFill = splitPaths.filter((x) => x.startsWith('fill')).length > 0;
|
||||
const pathHasFill =
|
||||
splitPaths.filter((x) => x.startsWith('fill')).length > 0;
|
||||
if (query.fill !== undefined || pathHasFill) {
|
||||
if ('fill' in query) {
|
||||
ctx.fillStyle = query.fill || 'rgba(255,255,255,0.4)';
|
||||
|
|
@ -538,6 +537,16 @@ const drawPath = (ctx, path, query, z) => {
|
|||
ctx.strokeStyle = 'rgba(0,64,255,0.7)';
|
||||
}
|
||||
ctx.stroke();
|
||||
};
|
||||
|
||||
// Check if path in query is valid
|
||||
if (Array.isArray(query.path)) {
|
||||
for (let i = 0; i < query.path.length; i += 1) {
|
||||
renderPath(query.path.at(i).split('|'));
|
||||
}
|
||||
} else {
|
||||
renderPath(query.path.split('|'));
|
||||
}
|
||||
};
|
||||
|
||||
const renderOverlay = async (
|
||||
|
|
|
|||
Loading…
Reference in a new issue