Leaflet draw edit control custom text

懵懂的女人 提交于 2021-02-10 05:31:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!