问题
I'd like to change the options text from edit control at Leaflet Draw. So instead of Save
|Cancel
|Clear All
Display this text in another language. Same on the tooltips. Is it possible?
回答1:
I solved in this way.
L.drawLocal = {
draw: {
toolbar: {
// #TODO: this should be reorganized where actions are nested in actions
// ex: actions.undo or actions.cancel
actions: {
title: 'Cancel - your text-',
text: '- your text-'
},
finish: {
title: '- your text-',
text: '- your text-'
},
undo: {
title: '- your text-',
text: '- your text-'
},
buttons: {
polyline: '- your text-',
polygon: '- your text-',
rectangle: '- your text-',
circle: '- your text-',
marker: '- your text-',
circlemarker: '- your text-'
}
},
handlers: {
circle: {
tooltip: {
start: '- your text-'
},
radius: '- your text-'
},
circlemarker: {
tooltip: {
start: '- your text-.'
}
},
marker: {
tooltip: {
start: '- your text-.'
}
},
polygon: {
tooltip: {
start: '- your text-.',
cont: '- your text-.',
end: '- your text-.'
}
},
polyline: {
error: '<strong>Error:</strong> shape edges cannot cross!',
tooltip: {
start: 'Click to start drawing line.',
cont: 'Click to continue drawing line.',
end: 'Click last point to finish line.'
}
},
rectangle: {
tooltip: {
start: '- your text-.'
}
},
simpleshape: {
tooltip: {
end: 'Release mouse to finish drawing.'
}
}
}
},
edit: {
toolbar: {
actions: {
save: {
title: 'Save changes',
text: 'Save'
},
cancel: {
title: 'Cancel editing, discards all changes',
text: 'Cancel'
},
clearAll: {
title: 'Clear all layers',
text: 'Clear All'
}
},
buttons: {
edit: 'Edit layers',
editDisabled: 'No layers to edit',
remove: 'Delete layers',
removeDisabled: 'No layers to delete'
}
},
handlers: {
edit: {
tooltip: {
text: 'Drag handles or markers to edit features.',
subtext: 'Click cancel to undo changes.'
}
},
remove: {
tooltip: {
text: 'Click on a feature to remove.'
}
}
}
}
};
来源:https://stackoverflow.com/questions/48661724/leaflet-draw-edit-control-custom-text