Leaflet Map Util—Leaflet内部使用的各种实用功能

Leaflet Map Util—Leaflet内部使用的各种实用功能

Functions

FunctionReturnsDescription
extend(<Object> dest, <Object> 
src?)
ObjectMerges the properties of the src object (or multiple objects) into dest object and returns the latter. Has an L.extend shortcut.
将src对象(或多个对象)的属性合并到dest对象并返回后者。有一个L.extend快捷方式。
create(<Object> proto, <Object>
 properties?)
ObjectCompatibility polyfill for Object.create
Object.create的兼容性polyfill
bind(<Function> fn)FunctionReturns a new function bound to the arguments passed, like Function.prototype.bind. Has a L.bind() shortcut.
返回绑定到传递的参数的新函数,如function.prototype.bind。有一个L.bind()快捷方式。
stamp(<Object> obj)NumberReturns the unique ID of an object, assigning it one if it doesn’t have it.
返回对象的唯一ID,如果没有,则为其分配一个ID。
throttle(<Function> fn
<Number> time, <Object> context)
FunctionReturns a function which executes function fn with the given scope context (so that the this keyword refers to context inside fn‘s code). The function fn will be called no more than one time per given amount of time. The arguments received by the bound function will be any arguments passed when binding the function, followed by any arguments passed when invoking the bound function. Has an L.throttle shortcut.
返回一个函数,该函数使用给定的作用域上下文执行函数fn(因此this关键字引用fn代码中的上下文)。函数fn在给定时间内被调用的次数不超过一次。绑定函数接收的参数将是绑定函数时传递的任何参数,然后是调用绑定函数时的任何参数。有一个左油门快捷键。
wrapNum(<Number> num
<Number[]> range,
 <Boolean> includeMax?)
NumberReturns the number num modulo range in such a way so it lies within range[0] and range[1]. The returned value will be always smaller than range[1] unless includeMax is set to true.
返回数字num的模范围,使其位于范围[0]和范围[1]内。除非includeMax设置为true,否则返回的值将始终小于范围[1]。
falseFn()FunctionReturns a function which always returns false.
返回始终返回false的函数。
formatNum(<Number> num
<Number|false> precision?)
NumberReturns the number num rounded with specified precision. The default precision value is 6 decimal places. false can be passed to skip any processing (can be useful to avoid round-off errors).
返回以指定精度舍入的数字num。默认精度值为6位小数。可以传递false来跳过任何处理(这对于避免舍入错误非常有用)。
trim(<String> str)StringCompatibility polyfill for String.prototype.trim
String.prototype.trim的兼容性polyfill
splitWords(<String> 
str)
String[]Trims and splits the string on whitespace and returns the array of parts.
在空白处修剪和拆分字符串,并返回部分数组。
setOptions(<Object> obj,
 <Object> options)
ObjectMerges the given properties to the options of the obj object, returning the resulting options. See Class options. Has an L.setOptions shortcut.
将给定属性合并到obj对象的选项,并返回结果选项。请参见类选项。具有L.setOptions快捷方式。
getParamString(<Object>
 obj, <String> existingUrl?,
 <Boolean> uppercase?)
StringConverts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} translates to '?a=foo&b=bar'. If existingUrl is set, the parameters will be appended at the end. If uppercase is true, the parameter names will be uppercased (e.g. '?A=foo&B=bar')
将对象转换为参数URL字符串,例如{a:“foo”,b:“bar”}转换为‘?a=foo&b=bar’。如果设置了existingUrl,则参数将附加在末尾。如果大写为真,参数名称将大写(例如“?A=foo&B=bar”)
template(<String> str
<Object> data)
StringSimple templating facility, accepts a template string of the form 'Hello {a}, {b}' and a data object like {a: 'foo', b: 'bar'}, returns evaluated string ('Hello foo, bar'). You can also specify functions instead of strings for data values — they will be evaluated passing data as an argument.
简单的模板工具,接受形式为“Hello{a},{b}”的模板字符串和数据对象,如{a:‘foo’,b:‘bar’},返回求值字符串(‘Hello foo,bar’)。您还可以为数据值指定函数而不是字符串-它们将作为参数传递数据。
isArray(obj)BooleanCompatibility polyfill for Array.isArray
Array.isArray的兼容性polyfill
indexOf(<Array> array
Object> el)
NumberCompatibility polyfill for Array.prototype.indexOf
Array.prototype.indexOf的兼容性polyfill
requestAnimFrame(<Function> fn,
 <Object> context?, <Boolean>
 immediate?)
NumberSchedules fn to be executed when the browser repaints. fn is bound to context if given. When immediate is set, fn is called immediately if the browser doesn’t have native support for window.requestAnimationFrame, otherwise it’s delayed. Returns a request ID that can be used to cancel the request.
计划fn在浏览器重新绘制时执行。如果给定,fn与上下文绑定。设置immediate时,如果浏览器不支持窗口,则立即调用fn。requestAnimationFrame,否则会延迟。返回可用于取消请求的请求ID。
cancelAnimFrame(<Number> id)undefinedCancels a previous requestAnimFrame. See also window.cancelAnimationFrame.
取消先前的请求AnimFrame。另请参见window.cancelAnimationFrame。

Properties

PropertyTypeDescription
lastIdNumberLast unique ID used by stamp()
stamp()使用的最后一个唯一ID
emptyImageUrlStringData URI string containing a base64-encoded empty GIF image. Used as a hack to free memory from unused images on WebKit-powered mobile devices (by setting image src to this string).
包含base64编码的空GIF图像的数据URI字符串。用于破解WebKit驱动的移动设备上未使用的图像中的内存(通过将图像src设置为此字符串)。
0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x