Skip to content

Commit

Permalink
point-text option in -style to provide text tag symbol as point
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricsam committed Feb 6, 2019
1 parent d679afc commit 4ad83b0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/cli/mapshaper-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,9 @@ internal.getOptionParser = function() {
.option("label-text", {
describe: 'label text (set this to export points as labels)'
})
.option("point-text", {
describe: 'point symbol text (a text symbol replaces path or circle)'
})
.option("text-anchor", {
describe: 'label alignment; one of: start, end, middle (default)'
})
Expand Down
2 changes: 1 addition & 1 deletion src/commands/mapshaper-svg-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ api.svgStyle = function(lyr, dataset, opts) {
};

internal.isSupportedSvgProperty = function(name) {
return SVG.supportedProperties.indexOf(name) > -1 || name == 'label-text';
return SVG.supportedProperties.indexOf(name) > -1 || name == 'label-text' || name == 'point-text';
};

// returns parsed value or null if @strVal is not recognized as a valid literal value
Expand Down
15 changes: 14 additions & 1 deletion src/svg/geojson-to-svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,20 @@ SVG.importStandardPoint = function(coords, rec, layerOpts) {
// if not a label, create a symbol even without a size
// (circle radius can be set via CSS)
if (halfSize > 0 || !isLabel) {
if (symbolType == 'square') {
if (symbolType == 'text') {
p = {
tag: 'text',
properties: {
x: coords[0],
y: coords[1],
dx: 0,
dy: rec['font-size'] ? rec['font-size'] / 4 : 7,
'font-size': rec['font-size'] ? rec['font-size'] - 2 : 10,
'text-anchor': 'middle'
},
value: rec['point-text'] ? rec['point-text'] : '●'
}
} else if (symbolType == 'square') {
p = {
tag: 'rect',
properties: {
Expand Down

0 comments on commit 4ad83b0

Please sign in to comment.