在Openlayers中,为什么setUrl仅可用于平铺向量

在Openlayers中,为什么setUrl仅可用于平铺向量,openlayers,Openlayers,为什么setUrl可用于平铺层而不可用于矢量层 在ol/source/WMTS.js、ol/source/UrlTile.js中有一个setUrl函数,然后将其导入ol/source/VectorTile.js和ol/source/ImageWMS.js,但在ol/source/Vector.js中没有?如果需要更改矢量层的URL,您会怎么做 谢谢 Jim在ol.source.Vector中的url选项可以是一个函数: var myUrl; myUrlFunction = function()

为什么setUrl可用于平铺层而不可用于矢量层

在ol/source/WMTS.js、ol/source/UrlTile.js中有一个setUrl函数,然后将其导入ol/source/VectorTile.js和ol/source/ImageWMS.js,但在ol/source/Vector.js中没有?如果需要更改矢量层的URL,您会怎么做

谢谢
Jim

ol.source.Vector
中的
url
选项可以是一个函数:

var myUrl;
myUrlFunction = function() {
  return myUrl;
}

source = new ol.source.Vecor({
  url: myUrlFunction,
})
因此,您可以根据需要设置
myUrl