MCPcopy Create free account
hub / github.com/StephanGeorg/staticmaps / textToSVG

Method textToSVG

src/staticmaps.js:351–371  ·  view source on GitHub ↗

* Render text to SVG

(text)

Source from the content-addressed store, hash-verified

349 * Render text to SVG
350 */
351 textToSVG(text) {
352 const mapcoords = [
353 this.xToPx(geoutils.lonToX(text.coord[0], this.zoom)) - text.offset[0],
354 this.yToPx(geoutils.latToY(text.coord[1], this.zoom)) - text.offset[1],
355 ];
356
357 return `
358 <text
359 x="${mapcoords[0]}"
360 y="${mapcoords[1]}"
361 style="fill-rule: inherit; font-family: ${text.font};"
362 font-size="${text.size}pt"
363 stroke="${text.color}"
364 fill="${text.fill ? text.fill : 'none'}"
365 stroke-width="${text.width}"
366 text-anchor="${text.anchor}"
367 >
368 ${text.text}
369 </text>
370 `;
371 }
372
373 /**
374 * Render MultiPolygon to SVG

Callers 1

drawFeaturesMethod · 0.95

Calls 2

xToPxMethod · 0.95
yToPxMethod · 0.95

Tested by

no test coverage detected