Leaflet Map TileLayer.WMS—用于在地图上将 WMS 服务显示为切片图层

Leaflet Map TileLayer.WMS—用于在地图上将 WMS 服务显示为切片图层

用于在地图上将 WMS 服务显示为切片图层。扩展 TileLayer。

使用示例

var nexrad = L.tileLayer.wms("http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", {
    layers: 'nexrad-n0r-900913',
    format: 'image/png',
    transparent: true,
    attribution: "Weather data © 2012 IEM Nexrad"
});

创建

FactoryDescription
L.tileLayer.wms(<String> baseUrl, <TileLayer.WMS optionsoptions)Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object.
在给定 WMS 服务的基本 URL 和 WMS 参数/选项对象的情况下实例化 WMS 切片图层对象。

Options

If any custom options not documented here are used, they will be sent to the WMS server as extra parameters in each request URL. This can be useful for non-standard vendor WMS parameters.

如果使用了此处未记录的任何自定义选项,它们将作为每个请求 URL 中的额外参数发送到 WMS 服务器。这对于非标准供应商 WMS 参数很有用。

OptionTypeDefaultDescription
layersString''(required) Comma-separated list of WMS layers to show.
(必需)要显示的 WMS 图层的逗号分隔列表。
stylesString''Comma-separated list of WMS styles.
WMS 样式的逗号分隔列表。
formatString'image/jpeg'WMS image format (use 'image/png' for layers with transparency).
WMS 图像格式(对具有透明度的图层使用“图像/png”)。
transparentBooleanfalseIf true, the WMS service will return images with transparency.
如果为 true,WMS 服务将返回具有透明度的图像。
versionString'1.1.1'Version of the WMS service to use.
要使用的 WMS 服务版本
crsCRSnullCoordinate Reference System to use for the WMS requests, defaults to map CRS. Don’t change this if you’re not sure what it means.
用于 WMS 请求的坐标参考系统,默认为地图 CRS。如果您不确定它的含义,请不要更改它。
uppercaseBooleanfalseIf true, WMS request parameter keys will be uppercase.
如果为 true,WMS 请求参数键将为大写。

▶ Options inherited from TileLayer

从 TileLayer 继承的选项

OptionTypeDefaultDescription
minZoomNumber0The minimum zoom level down to which this layer will be displayed (inclusive).
此图层将显示的最小缩放级别(包括)。
maxZoomNumber18The maximum zoom level up to which this layer will be displayed (inclusive).
此图层将显示的最大缩放级别(包括)。
subdomainsString|String[]'abc'Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings.
磁贴服务的子域。可以以一个字符串(其中每个字母是一个子域名)或字符串数​​组的形式传递。
errorTileUrlString''URL to the tile image to show in place of the tile that failed to load.
用于代替加载失败的图块显示的图块图像的 URL。
zoomOffsetNumber0The zoom number used in tile URLs will be offset with this value.
平铺 URL 中使用的缩放数字将使用此值进行偏移。
tmsBooleanfalseIf true, inverses Y axis numbering for tiles (turn this on for TMS services).
如果为真,则反转图块的 Y 轴编号(为 TMS 服务启用此选项)。
zoomReverseBooleanfalseIf set to true, the zoom number used in tile URLs will be reversed (maxZoom - zoom instead of zoom)
如果设置为 true,则磁贴 URL 中使用的缩放数字将反转(maxZoom – 缩放而不是缩放)
detectRetinaBooleanfalseIf true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.
如果为真并且用户在视网膜显示器上,它将请求四个大小为指定大小一半的图块和更大的缩放级别来代替一个以利用高分辨率。
crossOriginBoolean|StringfalseWhether the crossOrigin attribute will be added to the tiles. If a String is provided, all tiles will have their crossOrigin attribute set to the String provided. This is needed if you want to access tile pixel data. Refer to CORS Settings for valid String values.
是否将 crossOrigin 属性添加到图块中。如果提供了字符串,则所有图块的 crossOrigin 属性都将设置为提供的字符串。如果您想访问平铺像素数据,则需要这样做。有关有效的字符串值,请参阅 CORS 设置。
referrerPolicyBoolean|StringfalseWhether the referrerPolicy attribute will be added to the tiles. If a String is provided, all tiles will have their referrerPolicy attribute set to the String provided. This may be needed if your map’s rendering context has a strict default but your tile provider expects a valid referrer (e.g. to validate an API token). Refer to HTMLImageElement.referrerPolicy for valid String values.
是否将referrerPolicy 属性添加到图块中。如果提供了字符串,则所有图块都将其 referrerPolicy 属性设置为提供的字符串。如果您的地图的渲染上下文具有严格的默认值,但您的图块提供者需要一个有效的引用者(例如,验证 API 令牌),则可能需要这样做。有关有效的字符串值,请参阅 HTMLImageElement.referrerPolicy。

▶ Options inherited from GridLayer

从 GridLayer 继承的选项

OptionTypeDefaultDescription
tileSizeNumber|Point256Width and height of tiles in the grid. Use a number if width and height are equal, or L.point(width, height) otherwise.
网格中瓷砖的宽度和高度。如果宽度和高度相等,则使用数字,否则使用 L.point(width, height)。
opacityNumber1.0Opacity of the tiles. Can be used in the createTile() function.
瓷砖的不透明度。可在 createTile() 函数中使用。
updateWhenIdleBoolean(depends)Load new tiles only when panning ends. true by default on mobile browsers, in order to avoid too many requests and keep smooth navigation. false otherwise in order to display new tiles during panning, since it is easy to pan outside the keepBuffer option in desktop browsers.
仅在平移结束时加载新图块。在移动浏览器上默认为 true,以避免过多的请求并保持流畅的导航。 false 否则为了在平移期间显示新图块,因为在桌面浏览器中很容易在keepBuffer 选项之外平​​移。
updateWhenZoomingBooleantrueBy default, a smooth zoom animation (during a touch zoom or a flyTo()) will update grid layers every integer zoom level. Setting this option to false will update the grid layer only when the smooth animation ends.
默认情况下,平滑的缩放动画(在触摸缩放或 flyTo() 期间)将在每个整数缩放级别更新网格层。将此选项设置为 false 将仅在平滑动画结束时更新网格层。
updateIntervalNumber200Tiles will not update more than once every updateInterval milliseconds when panning.
平移时,磁贴不会每 updateInterval 毫秒更新一次以上。
zIndexNumber1The explicit zIndex of the tile layer.
切片层的显式 zIndex。
boundsLatLngBoundsundefinedIf set, tiles will only be loaded inside the set LatLngBounds.
如果设置,则只会在设置的 LatLngBounds 内加载图块。
maxNativeZoomNumberundefinedMaximum zoom number the tile source has available. If it is specified, the tiles on all zoom levels higher than maxNativeZoom will be loaded from maxNativeZoom level and auto-scaled.
平铺源可用的最大缩放数。如果指定,则所有高于 maxNativeZoom 的缩放级别的图块将从 maxNativeZoom 级别加载并自动缩放。
minNativeZoomNumberundefinedMinimum zoom number the tile source has available. If it is specified, the tiles on all zoom levels lower than minNativeZoom will be loaded from minNativeZoom level and auto-scaled.
平铺源可用的最小缩放数。如果指定,则所有低于 minNativeZoom 的缩放级别的图块将从 minNativeZoom 级别加载并自动缩放。
noWrapBooleanfalseWhether the layer is wrapped around the antimeridian. If true, the GridLayer will only be displayed once at low zoom levels. Has no effect when the map CRS doesn’t wrap around. Can be used in combination with bounds to prevent requesting tiles outside the CRS limits.
该层是否缠绕在反子午线周围。如果为 true,则 GridLayer 将仅在低缩放级别显示一次。当地图 CRS 不环绕时无效。可以与边界结合使用,以防止请求超出 CRS 限制的图块。
paneString'tilePane'Map pane where the grid layer will be added.
将添加网格图层的地图窗格。
classNameString''A custom class name to assign to the tile layer. Empty by default.
要分配给切片图层的自定义类名称。默认为空。
keepBufferNumber2When panning the map, keep this many rows and columns of tiles before unloading them.
平移地图时,在卸载之前保留这么多行和列的图块。

▶ Options inherited from Layer

从图层继承的选项

OptionTypeDefaultDescription
attributionStringnullString to be shown in the attribution control, e.g. “© OpenStreetMap contributors”. It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
要在归因控件中显示的字符串,例如“© OpenStreetMap 贡献者”。它描述了图层数据,并且通常是对版权所有者和切片提供者的法律义务。

Events

▶ Extension methods inherited from TileLayer

从 TileLayer 继承的扩展方法

EventDataDescription
tileabortTileEventFired when a tile was loading but is now not wanted.
当瓷砖正在加载但现在不需要时触发。

▶ Events inherited from GridLayer

EventDataDescription
loadingEventFired when the grid layer starts loading tiles.
当网格层开始加载瓦片时触发。
tileunloadTileEventFired when a tile is removed (e.g. when a tile goes off the screen).
当一个 tile 被移除时触发(例如,当一个 tile 离开屏幕时)。
tileloadstartTileEventFired when a tile is requested and starts loading.
在请求 tile 并开始加载时触发。
tileerrorTileErrorEventFired when there is an error loading a tile..
加载图块出错时触发。
tileloadTileEventFired when a tile loads.
瓦片加载时触发。
loadEventFired when the grid layer loaded all visible tiles.
当网格层加载所有可见图块时触发。

▶ Events inherited from Layer

从图层继承的事件

EventDataDescription
addEventFired after the layer is added to a map
在图层添加到地图后触发
removeEventFired after the layer is removed from a map
从地图中移除图层后触发

▶ Popup events inherited from Layer

从图层继承的弹出事件

EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
打开绑定到该层的弹出窗口时触发
popupclosePopupEventFired when a popup bound to this layer is closed
当绑定到该层的弹出窗口关闭时触发

▶ Tooltip events inherited from Layer

从图层继承的工具提示事件

EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
打开绑定到此图层的工具提示时触发。
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
当绑定到该层的工具提示关闭时触发。

Methods

MethodReturnsDescription
setParams(<Object> params,
 <Boolean> noRedraw?)
thisMerges an object with the new parameters and re-requests tiles on the current screen (unless noRedraw was set to true).
将对象与新参数合并并重新请求当前屏幕上的图块(除非 noRedraw 设置为 true)。

▶ Methods inherited from TileLayer

从 TileLayer 继承的方法

MethodReturnsDescription
setUrl(<String> url, <Boolean> noRedraw?)thisUpdates the layer’s URL template and redraws it (unless noRedraw is set to true). If the URL does not change, the layer will not be redrawn unless the noRedraw parameter is set to false.
更新图层的 URL 模板并重新绘制(除非 noRedraw 设置为 true)。如果 URL 没有改变,图层将不会被重绘,除非 noRedraw 参数设置为 false。
createTile(<Object> coords,
<Function> done?)
HTMLElementCalled only internally, overrides GridLayer’s createTile() to return an <img> HTML element with the appropriate image URL given coords. The done callback is called when the tile has been loaded.
仅在内部调用,覆盖 GridLayer 的 createTile() 以返回具有给定坐标的适当图像 URL 的 <img> HTML 元素。加载磁贴时调用 done 回调。

▶ Methods inherited from GridLayer

从 GridLayer 继承的方法

MethodReturnsDescription
bringToFront()thisBrings the tile layer to the top of all tile layers.
将切片图层置于所有切片图层的顶部。
bringToBack()thisBrings the tile layer to the bottom of all tile layers.
将切片图层置于所有切片图层的底部。
getContainer()HTMLElementReturns the HTML element that contains the tiles for this layer.
返回包含此图层的切片的 HTML 元素。
setOpacity(<Number> opacity)thisChanges the opacity of the grid layer.
更改网格层的不透明度。
setZIndex(<Number> zIndex)thisChanges the zIndex of the grid layer.
更改网格层的 zIndex。
isLoading()BooleanReturns true if any tile in the grid layer has not finished loading.
如果网格层中的任何图块尚未完成加载,则返回 true。
redraw()thisCauses the layer to clear all the tiles and request them again.
使图层清除所有切片并再次请求它们。
getTileSize()PointNormalizes the tileSize option into a point. Used by the createTile() method.
将 tileSize 选项标准化为一个点。由 createTile() 方法使用。

▶ Methods inherited from Layer

从图层继承的方法

MethodReturnsDescription
addTo(<Map|LayerGroup> map)thisAdds the layer to the given map or layer group.
将图层添加到给定的地图或图层组。
remove()thisRemoves the layer from the map it is currently active on.
从当前处于活动状态的地图中移除图层。
removeFrom(<Mapmap)thisRemoves the layer from the given map
从给定地图中删除图层
removeFrom(<LayerGroup>
 group)
thisRemoves the layer from the given LayerGroup
从给定的图层组中移除图层
getPane(<String> name?)HTMLElementReturns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.
返回表示地图上命名窗格的 HTMLElement。如果省略名称,则返回此图层的窗格。
getAttribution()StringUsed by the attribution control, returns the attribution option.
由归因控制使用,返回归因选项。

▶ Popup methods inherited from Layer

从图层继承的弹出方法

MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup>
 content, <Popup optionsoptions?)
thisBinds a popup to the layer with the passed content and sets up the necessary event listeners. If a Function is passed it will receive the layer as the first argument and should return a String or HTMLElement.
使用传递的内容将弹出窗口绑定到图层并设置必要的事件侦听器。如果传递了一个函数,它将接收图层作为第一个参数,并应返回一个字符串或 HTMLElement。
unbindPopup()thisRemoves the popup previously bound with bindPopup.
移除之前与 bindPopup 绑定的弹出窗口。
openPopup(<LatLnglatlng?)thisOpens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.
如果未传递任何 latlng,则在指定的 latlng 或默认弹出窗口锚点处打开绑定弹出窗口。
closePopup()thisCloses the popup bound to this layer if it is open.
如果该层打开,则关闭绑定到该层的弹出窗口。
togglePopup()thisOpens or closes the popup bound to this layer depending on its current state.
根据当前状态打开或关闭绑定到该层的弹出窗口。
isPopupOpen()booleanReturns true if the popup bound to this layer is currently open.
如果绑定到此图层的弹出窗口当前打开,则返回 true。
setPopupContent(<String|HTMLElement|Popup>
 content)
thisSets the content of the popup bound to this layer.
设置绑定到该层的弹出窗口的内容。
getPopup()PopupReturns the popup bound to this layer.
返回绑定到该层的弹出窗口。

▶ Tooltip methods inherited from Layer

从图层继承的工具提示方法

MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip>
 content, <Tooltip optionsoptions?)
thisBinds a tooltip to the layer with the passed content and sets up the necessary event listeners. If a Function is passed it will receive the layer as the first argument and should return a String or HTMLElement.
使用传递的内容将工具提示绑定到图层并设置必要的事件侦听器。如果传递了一个函数,它将接收图层作为第一个参数,并应返回一个字符串或 HTMLElement。
unbindTooltip()thisRemoves the tooltip previously bound with bindTooltip.
移除之前与 bindTooltip 绑定的工具提示。
openTooltip(<LatLnglatlng?)thisOpens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.
如果未传递任何 latlng,则在指定的 latlng 或默认的工具提示锚点处打开绑定的工具提示。
closeTooltip()thisCloses the tooltip bound to this layer if it is open.
如果此图层打开,则关闭绑定到此图层的工具提示。
toggleTooltip()thisOpens or closes the tooltip bound to this layer depending on its current state.
根据其当前状态打开或关闭绑定到此图层的工具提示。
isTooltipOpen()booleanReturns true if the tooltip bound to this layer is currently open.
如果绑定到此图层的工具提示当前打开,则返回 true。
setTooltipContent(<String|HTMLElement|Tooltip>
 content)
thisSets the content of the tooltip bound to this layer.
设置绑定到该图层的工具提示的内容。
getTooltip()TooltipReturns the tooltip bound to this layer.
返回绑定到该图层的工具提示。

▶ Methods inherited from Evented

继承自 Evented 的方法

MethodReturnsDescription
on(<String> type, <Function>
 fn, <Object> context?)
thisAdds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').
将侦听器函数 (fn) 添加到对象的特定事件类型。您可以选择指定侦听器的上下文(this 关键字将指向的对象)。您还可以传递几种以空格分隔的类型(例如“click dblclick”)。
on(<Object> eventMap)thisAdds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
添加一组类型/侦听器对,例如{点击:onClick,鼠标移动:onMouseMove}
off(<String> type, <Function>
 fn?, <Object> context?)
thisRemoves a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.
删除以前添加的侦听器函数。如果未指定函数,它将从对象中删除该特定事件的所有侦听器。请注意,如果您将自定义上下文传递给 on,则必须将相同的上下文传递给 off 才能移除侦听器。
off(<Object> eventMap)thisRemoves a set of type/listener pairs.
删除一组类型/侦听器对。
off()thisRemoves all listeners to all events on the object. This includes implicitly attached events.
删除对象上所有事件的所有侦听器。这包括隐式附加事件。
fire(<String> type, <Object>
 data?, <Boolean> propagate?)
thisFires an event of the specified type. You can optionally provide a data object — the first argument of the listener function will contain its properties. The event can optionally be propagated to event parents.
触发指定类型的事件。您可以选择提供一个数据对象——侦听器函数的第一个参数将包含其属性。可以选择将事件传播到事件父级。
listens(<String> type
<Boolean> propagate?)
BooleanReturns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.
如果特定事件类型附加了任何侦听器,则返回 true。验证可以选择传播,如果父母有监听器附加到它,它将返回 true。
once()thisBehaves as on(…), except the listener will only get fired once and then removed.
表现为 on(…),除了监听器只会被触发一次然后被移除。
addEventParent(<Eventedobj)thisAdds an event parent – an Evented that will receive propagated events
添加事件父级 – 将接收传播事件的事件
removeEventParent(<Eventedobj)thisRemoves an event parent, so it will stop receiving propagated events
删除事件父级,因此它将停止接收传播的事件
addEventListener()thisAlias to on(…)
removeEventListener()thisAlias to off(…)
clearAllEventListeners()thisAlias to off()
addOneTimeEventListener()thisAlias to once(…)
fireEvent()thisAlias to fire(…)
hasEventListeners()BooleanAlias to listens(…)
0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x